我使用了以下 PHP 代码通过 SMTP 主机发送邮件:
ini_set('SMTP','myserver');
ini_set('smtp_port',25);
$to = $email;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers .= "From: NO-REPLY<no-reply@mydomain.com>" . "\r\n";
$subject = "Confirmation For Request";
$message = '<html>
<body>
<p>Hi '.$firstname.' '.$lastname.'</p>
<p>
We recieved below details from you. Please use given Request/Ticket ID for future follow up:
</p>
<p>
Your Request/Ticket ID: <b>'.$ticketID.'</b>
</p>
<p>
Thanks,<br>
'.$team.' Team.
</p>
</body>
</html>';
mail( $to, $subject, $message, $headers );
现在当我在本地的Windows上执行代码时,我成功地接收到邮件,但是如果我将相同的代码部署到Linux设置中,则不会收到任何邮件,尽管在Linux机器上mail()函数返回true。在查看了Windows本地主机和Linux服务器的phpinfo中的邮件参数后,我发现一个区别:在Windows中,sendmail_path ==“No Value”,而在Linux服务器上则显示“usr/sbin/sendmail-t-i”。有人能帮助我解决这个问题吗?注意:在Windows上,它是WAMP设置,而Linux是专用服务器。