DATA: 2018年07月09日 16:27:21
CentOS7
系统php
版本从5.3
升级至5.6
后,原本的邮件发送功能失效。查阅资料解决并笔记之。
php发送邮件主要代码实现
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: <'.$msg->email.'>' . "\r\n";
$myEmail = "dream@yixzm.cn";
mail($myEmail, $msg->subject, $msg->edit, $headers);
打开etc
下的php
配置文件:/etc/php.ini
,取消sendmail_path
的注释
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = /usr/sbin/sendmail -t -i
测试sendmail
,报错:
sendmail: fatal: parameter inet_interfaces: no local interface found for ::1
参考博文: send-mail: fatal: parameter inet_interfaces: no local interface found for ::1
将main.cf
中的init_interface
配置localhost
改为all
vi /etc/postfix/main.cf
inet_interfaces = all
至此,问题解决