[Chinese]利用msmtp和sendmail实现在linux的控制台(console)上使用smtp协议(网易免费邮箱)发邮件。
Sometimes I need build a FW image and send the image url to my colleague with image version via Email.So I would be glad be very glad to let build script do that job.
At first, I just need install a msmtp and sendmail to my hardy.
roro@anima:~$ sudo apt-get install msmtp sendmail
and setting up the msmtp with my 163 mail account.See detail below
~/.msmtprc
#Set default values for all following accounts.
defaults
#secure plain
#auth plain
#auth login
#authentication plain
tls off
port 25
#tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log
# A freemail service
account 163
host smtp.163.com
from robearro@163.com
auth login
user robearro@163.com
password ************
syslog on
# A second mail address at the same freemail service
#account freemail2 : freemail
#from [email]joey@freemail.exam[/email]ple
account default : 163
Here, I need thanks google and JoeCen's 小猫窝(its url is that: ), and there is the mstp manual page ().
Then config the mail setting.
~/.mailrc
set sendmail="/usr/bin/msmtp"
I tested, and it works.
roro@anima:~$ mail -s "test" mail@address < ./mainbody.txt
Later I would like to see if the msmtp support Microsoft Exchange Server.
Appendix A -- MSMTP ERROR
- msmtp: cannot use a secure authentication method
In msmtprc, the "auth" section, set it according to your mail server setting.
'auth' accepted methods are ‘plain’, ‘cram-md5’, ‘digest-md5’, ‘gssapi’, ‘external’, ‘login’, and ‘ntlm’.
Mail.163.com supports 'login'. - send-mail: /home/roro/.msmtprc: must have no more than user read/write permissionsCan't send mail: sendmail process failed with error code 78
roro@anima ocsis30$ ls -l /home/roro/.msmtprc
-rw-r--r-- 1 roro root 689 2009-11-25 15:00 /home/roro/.msmtprc
roro@anima ocsis30$ chmod 600 ~/.msmtprc
roro@anima ocsis30$ ls -l /home/roro/.msmtprc
-rw------- 1 roro root 689 2009-11-25 15:00 /home/roro/.msmtprc
阅读(1086) | 评论(0) | 转发(0) |