BoyChai's Blog - smtp https://blog.boychai.xyz/index.php/tag/smtp/ SendMail-邮件服务器搭建 https://blog.boychai.xyz/index.php/archives/21/ 2022-07-22T12:08:00+00:00 环境: rocky8.5 selinux和防护墙关闭。安装: yum -y install sendmail sendmail-cf配置:编辑/etc/mail/sendmail.mc,大概在121行这个Addr参数就是指定监听的ip,把127.0.0.1修改成自己的ip或者0.0.0.0,也可以修改成网段之类的,这里不多赘述。修改后保存退出。...... 119 dnl # address restriction to accept email from the internet or intranet. 120 dnl # 121 DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl 122 dnl # 123 dnl # The following causes sendmail to additionally listen to port 587 for ......sendmail的配置文件是由m4这个工具生成,使用下面命令生成配置文件m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf之后编辑/etc/mail/access,在最后面追加以下内容,意为谁可以使用这个服务器来进行发送邮件。网段形式的ip可以这样写"192.168.0"。Connect:0.0.0.0 RELAY启动:systemctl start sendmailtelnet测试邮件发送:# telnet 127.0.0.1 25 #连接sendmail服务器 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. 220 s ESMTP Sendmail 8.15.2/8.15.2; Sat, 23 Jul 2022 05:08:11 -0400 HELO boychai.xyz #和服务器说明我是那个域 250 s Hello localhost [127.0.0.1], pleased to meet you mail from:admin@boychai.xyz #发件人 250 2.1.0 admin@boychai.xyz... Sender ok rcpt to:1972567225@qq.com #收件人 250 2.1.5 1972567225@qq.com... Recipient ok data #发送内容 354 Enter mail, end with "." on a line by itself subject:hello #指定标题 hello sendmail #邮件内容 . #写好内容之后用"."结束 250 2.0.0 26N98BZR011316 Message accepted for delivery quit #退出 221 2.0.0 s closing connection Connection closed by foreign host.qq邮箱那边收到邮件之后可能会在垃圾桶里面,效果如下