ubuntu安装sendmail服务
参考:http://mymbk.blog.sohu.com/226462030.html?qq-pf-to=pcqq.c2c
cat /etc/hostname
1.sudo apt-get install sendmail -y
sudo apt-get install sendmail-cf
2.安装需要带附件的服务
sudo apt-get install mailutils
3.sudo vi /etc/mail/sendmail.mc
DAEMON_OPTIONS(`Family=inet, Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl
修改Addr=0.0.0.0 表明可以连接到任何服务器
DAEMON_OPTIONS(`Port=2500, Name=MTA')dnl
修改端口
4.sudo vi /etc/hosts 第一行 添加邮件域名地址
127.0.0.1 XXX.com hostname中的主机名 localhost
5.sudo vi /etc/mail/local-host-names 第一行 添加邮件域名地址
echo "XXX.com">>/etc/mail/local-host-names
XXX.com
6.sudo vi /etc/mail/access
Connect:hostname中的主机名 RELAY
Connect:localhost.localdomain RELAY
Connect:localhost RELAY
Connect:127.0.0.1
Connect:XXX.com RELAY
7.生成新的配置文件
cd /etc/mail
mv sendmail.cf sendmail.org
mv sendmail.cf sendmail.cf~
m4 sendmail.mc > sendmail.cf
8.配置sendmail
sendmailconfig
9./etc/init.d/sendmail restart
service sendmail restart
检测版本
netstat -napt|grep sendmail
telnet 127.0.0.1 25
10.echo "邮件正文" | mail -s 邮件主题 test@126.com
注意qq与163邮箱有时发送不成功