Ubuntu配置邮件发送

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/baidu_38432732/article/details/96883598
  1. sudo apt-get install heirloom-mailx  
  2. vi /etc/s-nail.rc  

在最后加入:

set from=ys.liu@grandideals.com
set smtp=smtps://smtp.exmail.qq.com:465
set smtp-auth-user=发送邮件邮箱
set smtp-auth-password=密码
set smtp-auth=login

说明:此处以qq邮箱为例,smtp为邮箱服务器,password是邮箱smtp密码,并非qq密码,获取方式如下:

 

第二步、发送邮件:

Shell代码 

  1. mail -s "邮件标题" "111111@qq.com" < content.txt   
展开阅读全文

邮件发送

11-27

CSocket Sock;rnchar sdata[255] = 0;rnchar sRecv[255] = 0;rnCString sResp;rnint n;rnrnSock.Create();rnrnSock.Connect("smtp.163.com",25);rnn = Sock.Receive(sRecv,255);rnsResp = sRecv;rnsResp = sResp.Left(3);rnif(sResp != "220")rnrn MessageBox("Connect Fail!");rn return;rnrn//返回220rnCString strH = "HELO Lijing\r\n";rnSock.Send(strH,strH.GetLength());rnn = Sock.Receive(sRecv,255);rnsResp = sRecv;rnsResp = sResp.Left(3);rnif(sResp != "250")rnrn return;rnrnrnCString strUser1 = "AUTH LOGIN\r\n";rnSock.Send(strUser1,strUser1.GetLength());rnn = Sock.Receive(sRecv,255);rnsResp = sRecv;rnMessageBox(sRecv);//返回334rnrnrnstrUser1 = "USER lj-aaaaaa2001\r\n";rnwsprintf(sdata, "%s%c%c", strUser1, 0x0d, 0x0a);rnrnSock.Send(sdata,strlen(sdata));rnrnn = Sock.Receive(sRecv,255);rnsResp = sRecv;rnMessageBox(sRecv);//返回334rnsResp = sResp.Left(3);rnif(sResp != "334")rnrn //MessageBox("Acount Fail!");rn //return;rnrnrnLPSTR strPwd = "PASS 121200\r\n";rnwsprintf(sdata,"%s%c%c",strPwd,0x0d,0x0a);rnrnSock.Send(sdata,strlen(sdata));rnn = Sock.Receive(sRecv,255);rnsResp = sRecv;rnMessageBox(sResp);//返回235rnsResp = sResp.Left(3);rnif(sResp != "220")rnrn //MessageBox("Password Fail!");rn //return;STATrnrnrnrnCString strUser = "MAIL FROM:\r\n";rnrnSock.Send(strUser,strUser.GetLength());rnrnn = Sock.Receive(sRecv,255);rnsResp = sRecv;rnMessageBox(sResp);rnsResp = sResp.Left(3);rnif(sResp != "250")rnrn //MessageBox("Acount Fail!");rn return;rnrnrnstrUser = "RCPT TO:\r\n";rnrnSock.Send(strUser,strUser.GetLength());rnrnn = Sock.Receive(sRecv,255);rnsResp = sRecv;rnMessageBox(sResp);rnsResp = sResp.Left(3);rnif(sResp != "250")rnrn //MessageBox("Pwd Fail!");rn return;rnrnrnstrUser = "DATA\r\n";rn//wsprintf(sdata, "%s%c%c", strUser, 0x0d, 0x0a);rnrnSock.Send(strUser,strlen(strUser));rnrnn = Sock.Receive(sRecv,255);rnsResp = sRecv;rnMessageBox(sResp);rnrnsResp = sResp.Left(3);rnif(sResp != "354")rnrn MessageBox("DATA Fail!");rn return;rnrnrnrnCString subject = "FROM:lj-aaaaaa2001@163.comTO:lj-aaaaaa2001@163.comSubject:Hello,World\r\nHello,How are you!\r\n.\r\n";rnrnSock.Send(subject,strlen(subject));rnrnn = Sock.Receive(sRecv,255);rnsResp = sRecv;rnMessageBox(sResp);rnrnsResp = sResp.Left(3);rnif(sResp != "220")rnrn //MessageBox("Acount Fail!");rn //return;rnrnCString sFree = "QUIT\r\n";rnrnSock.Send(sFree,strlen(sFree));rnrnn = Sock.Receive(sRecv,255);rnsResp = sRecv;rnMessageBox(sResp);rn根据RFC里面介绍,上面的返回值都没错,在最后居然弹出SMTP身份验证对话框,要求输入rn用户名和密码,如果取消,邮件不能成功发送,而且在我输入名字和密码后收到的邮件没有rn标题和内容,最奇怪的是,SMTP身份验证对话框有时不能弹出。不明白那里有问题,我在网rn上找了好多,都没有身份验证,发送不成功。如果谁有原码,请给我一份,拜托!rn 论坛

没有更多推荐了,返回首页