所以我已经安装了ssmpt并使用ssmpt成功测试了电子邮件发送。
现在的问题是,php邮件功能无法发送电子邮件。 我试过,php.ini中的以下配置
sendmail_path = sendmail -t -i
or
sendmail_path = /usr/sbin/ssmpt -t
or
sendmail_path = /usr/sbin/sendmail -t
我的简单php文件如下:
<?php
$to = "to@gmail.com";
$subject = "HTML email";
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
</body>
</html>";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
mail($to,$subject,$message,$headers);
?>