php 邮件功能在 windows 下运行良好,但在 linux 服务器上运行不佳

标签 php linux email

我使用的邮件功能在 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"; 

关于php 邮件功能在 windows 下运行良好,但在 linux 服务器上运行不佳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30165512/

相关文章:

email - Mailman 邮件列表 nntp 支持

email - 如何启用应用程序从谷歌容器引擎发送电子邮件

linux - gzip 输出后 Mysqldump 脚本未返回预期结果

linux - 从未知名称的文件夹中解压缩?

javascript - 如何在meteor中设置多个smtp设置?

php/mysql 更新非常大的表的更好选择

php - 运行 script.php 时出错 : Port 9000 is busy

php - 当文件本身不存在时,如何显示自定义 404 页面未找到页面?

php - 无法运行具有代码覆盖率的 Codeception 测试

php - 如果日期晚于