安装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

注意这里的密码是授权码不是账号的登录密码

image.png

测试发信echo "hello ihewro" | mail -v -s "" ihewro@163.com

至此一切搞定,详细的sendmail 配置,如加密链接或者更复杂的sendmail配置可以参考下面两篇文章:

最后修改:2022 年 04 月 24 日
喜欢我的文章吗?
别忘了点赞或赞赏,让我知道创作的路上有你陪伴。