Chinaunix首页 | 论坛 | 博客
  • 博客访问: 99915
  • 博文数量: 64
  • 博客积分: 2570
  • 博客等级: 少校
  • 技术积分: 605
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-24 11:00
文章分类

全部博文(64)

文章存档

2011年(1)

2010年(25)

2009年(38)

我的朋友

分类: LINUX

2009-11-25 11:24:27

[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

  1. 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'.
  2. 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) |
给主人留下些什么吧!~~