Linux 开启 mail 函数发送邮件及解决 sendmail 启动问题
网站出现留言或者询盘表单发送错误,通常是 sendmail 组件的问题。
sendmail 组件安装
安装 sendmail 组件
apt install sendmail
重启 php-fpm 进程
/etc/init.d/php-fpm restart
检测 sendmail 是否正常运行
/etc/init.d/sendmail status
如果显示正在运行 running 就可以。
可能用到的命令
/etc/init.d/sendmail start
/etc/init.d/sendmail stop
/etc/init.d/sendmail restart
解决发送邮件慢的问题
再次测试的时候,可能会发现成功发一封邮件很慢,要好几十秒甚至一分钟的时间。然后在博客中发表或者回复评论也是异常的慢,超过了用户等待的心理极限。
修改 /etc/hosts
修改之前
127.0.0.1 localhost
修改成
127.0.0.1 localhost.localdomain localhost 主机名称
查看本机的主机名称命令
hostname
完成修改之后重启 sendmail
service sendmail restart
现在应该一切正常了。