[root@vincent tmp]# yum install msmtp -y [root@vincent tmp]# whereis msmtp //以下/usr/bin/msmtp为msmtp的执行路径 msmtp: /usr/bin/msmtp /usr/share/man/man1/msmtp.1.gz
[root@vincent tmp]# yum install mutt -y [root@vincent tmp]# touch /var/log/mmlog //手工建立一条日志文件记录msmtp活动信息 [root@vincent tmp]# vi ~/.msmtprc //手工建立一个发送方的邮箱参数.msmtprc文件 account default host smtp.sina.cn port 25 from username@sina.cn auth login tls off user username@sina.cn password 123 logfile /var/log/mmlog :wq! [root@vincent tmp]# chmod 600 ~/.msmtprc //分配它有600权限 [root@vincent tmp]# vim /etc/Muttrc //指定发送邮件的的发送程序、发送方邮箱、中文支持 set sendmail="/usr/bin/msmtp" set use_from=yes set realname=‘33e9‘ //发送方的名字 set from=username@sina.cn set envelope_from=yes auto_view text/html set charset=‘utf-8‘ set send_charset=‘utf-8‘ set locale =‘zh_CN.UTF-8‘ set content_type = ‘text/html\;charset=utf-8‘ set rfc2047_parameters=yes :wq! echo "你好" |mutt -s "测试文件" username@163.com //接收方的邮箱 [root@vincent tmp]# touch /tmp/mailcontent.txt //建立一个邮件内容模板,如果没邮件内容可写,则只建空白文件即可。 mutt -s "关于线上MSTP和Internet带宽汇总`date -d "-1 days" +%F`" "接收方姓名<username@163.com>" -a /tmp/internet`date -d "-1 days" +%F`.csv </tmp/mailcontent.txt
原文:http://www.cnblogs.com/vincent-liang/p/6377591.html