我使用的邮件功能在 Windows 中运行良好,但在 Linux 服务器中却不行。我的代码有什么问题。任何人都可以为此提供一些想法/更好的解决方案。我还引用了一些 SMTP 选项,但在运行时都会抛出错误。
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$email_recipient = "staff@inpws.com";
$email_subject="hi";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: info@oktakes.com\r\n";
$headers .= "Reply-To: info@oktakes.com";
$email_result = mail($email_recipient, $email_subject, "hiuu", $headers);
if ($email_result){ echo "Email has been sent!"; }
else{ echo "Email has failed!"; }
?>
$email_header
不存在。
$email_result = mail($email_recipient, $email_subject, $email_contents, $headers);
并且在 $headers
变量的第三行中应该是 \r\n
而不是 \n
。
$headers .= "From: info@oktakes.com\r\n";
我是一名优秀的程序员,十分优秀!