【问题标题】:noreply@example.com not working (rackspace)noreply@example.com 不工作(机架空间)
【发布时间】:2013-08-19 08:28:09
【问题描述】:

我正在尝试使用 noreply 发送电子邮件,但它不起作用 - 它不会发送任何内容。我正在使用这个测试文件:

<?php
$to      = 'myemailhere';
$subject = 'You received an email message!';
$message = 'This is a message in the email body form.';
$headers = 'From: noreply@example.com' . "\r\n" .
    'Reply-To: noreply@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

可能是什么问题?顺便说一句,我正在使用 rackspacke,如果有人知道的话。

提前致谢!

【问题讨论】:

  • 有什么错误吗?此外,您可能想看看使用 PHPMailer。也可能是 Rackspace 限制了您发送邮件的选项...
  • 这可能与您的 SMTP 配置有关,不是编程问题。

标签: php email sendmail


【解决方案1】:

如果您在 Rackspace 云服务器上运行,您必须自己配置服务器才能发送邮件。 mail() 函数依赖于操作系统配置来处理电子邮件。如果您在 Rackspace 云站点上,您可能需要联系 Rackspace 支持以寻求帮助。

我个人通过使用 PEAR 的 SMTP 类完全避开了这个问题。这是 PHP 中的完整 SMTP 实现,因为它不依赖任何外部配置或模块,所以它是完全可移植的。它为我省去了很多麻烦。

http://pear.php.net/package/Mail

http://pear.php.net/package/Net_SMTP

注意:PEAR 网站对我来说有一些加载问题。稍等片刻,它应该会加载。

【讨论】:

    【解决方案2】:

    什么是异常?使用 try catch 块。否则试试这段代码

    $to = "someone@example.com";
    $subject = "Test mail";
    $message = "Hello! This is a simple email message.";
    $from = "someonelse@example.com";
    $headers = "From:" . $from;
    mail($to,$subject,$message,$headers);
    echo "Mail Sent.";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-01
      • 2013-05-22
      • 2012-03-28
      • 1970-01-01
      • 2013-08-28
      • 1970-01-01
      • 2014-09-04
      相关资源
      最近更新 更多