linux下sendmail

1. 安装

# yum install sendmail.x86_64

bin/mail会默认使用本地sendmail发送邮件,这样要求本地的机器必须安装和启动sendmail服务,配置非常麻烦,而且会带来不必要的资源占用
通过修改配置文件,可以使用外部的smtp服务器发送邮件

2. 配置

# vi /etc/mail.rc
set from=xxx@qq.com  
set smtp=smtp.qq.com 
set smtp-auth-user=xxx@qq.com  
set smtp-auth-password=password (账户密码)
set smtp-auth=login

from是发送的邮件地址
smtp是外部smtp服务器的地址
smtp-auth-user是外部smtp服务器认证的用户名
smtp-auth-password是外部smtp服务器认证的用户密码
smtp-auth是邮件认证的方式

3. 测试

# echo "hello word" | mail -s "test" xxx@heartsone.net
# mail -s "test" xxx@sohu.com <content.txt

-s是邮件主题
@是收件人
content是邮件正文

4. 设置ssl邮箱
复制证书文件
在裝有Firefox的Linux电脑,找到 ~/.mozilla/firefox/xxxxxxxx.default/ 的 cert*.db 与 key*.db

5. 配置

set ssl-verify=ignore
set nss-config-dir=/etc/pki/nssdb   //证书路径
set from=xxx@qq.com
set smtp=smtps://smtp.qq.com:465    //ssl端口
set smtp-auth-user=xxx@qq.com
set smtp-auth-password=password 
set smtp-auth=login

再次测试

posted @ 2015-06-12 17:42  thomas_blog  阅读(110)  评论(0编辑  收藏  举报