This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(26个答案)
4年前关闭。
我已经在Windows中使用了类似的邮件功能,但在Linux服务器中却无法使用。我的代码出了什么问题..任何人都可以为此提供一些想法/更好的解决方案。我也引用了一些SMTP选项,但是在运行时都会抛出错误运行。
在
(26个答案)
4年前关闭。
我已经在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
instrad。$headers .= "From: info@oktakes.com\r\n";