安装: yum -y install sendmail
启动:systemctl start sendmail.service
查看状态: systemctl status sendmail.service
发现有一个错误,提示无法识别hostname 对应的 domainname,因为我们的domain name不是一个域名格式。
Dec 28 21:46:48 VM-0-14-centos systemd[1]: Starting Sendmail Mail Transport Agent...
Dec 28 21:46:48 VM-0-14-centos sendmail[9384]: My unqualified host name (VM-0-14-centos) unknown; slee...etry
Dec 28 21:47:48 VM-0-14-centos sendmail[9384]: unable to qualify my own domain name (VM-0-14-centos) -...name
Dec 28 21:47:48 VM-0-14-centos sendmail[9593]: starting daemon (8.14.7): SMTP+queueing@01:00:00
Dec 28 21:47:48 VM-0-14-centos systemd[1]: Started Sendmail Mail Transport Agent.
Hint: Some lines were ellipsized, use -l to show in full.
编辑host文件:nano /etc/hosts
修改localhost的映射为一个域名格式
重启sendmail: systemctl restart sendmail.service
开启25端口: https://cloud.tencent.com/document/product/213/40436
在/etc/mail.rc
文件中配置stmp:
set from=ihewro@163.com
set smtp=smtp.163.com
set smtp-auth-user=ihewro@163.com
set smtp-auth-password=******(此处改成你自己的客户端授权码)
set smtp-auth=login
注意这里的密码是授权码不是账号的登录密码
测试发信: echo "hello ihewro" | mail -v -s "" ihewro@163.com
至此一切搞定,详细的sendmail 配置,如加密链接或者更复杂的sendmail配置可以参考下面两篇文章:
此处评论已关闭