【问题标题】:use PHP mail function on a server [duplicate]在服务器上使用 PHP 邮件功能 [重复]
【发布时间】:2017-01-24 03:28:56
【问题描述】:

我有一个表单,它从用户那里获取电子邮件,然后向该表单发送电子邮件,它在我的本地主机上运行良好,但是当我将代码传输到我的服务器 (Biz.nf) 时,我的用于发送电子邮件的 PHP 代码不再起作用。有什么建议我应该如何让它再次运行?

$to = $_POST['EM']; // this is your Email address
$subject = "Recipt ";
$message = "The following is your receipt " .$FName. "\n This email was sent too prove that this functionality is working";
mail($to,$subject,$message);

【问题讨论】:

  • 是否显示错误?

标签: php email server localhost hosting


【解决方案1】:

大多数主机处理电子邮件的方式略有不同,并且对有效的外发电子邮件应包含的内容有不同的想法。

邮件函数实际上还有另一个参数,'headers'...见documentation

您的主机可能因为缺少特定的标头而停止了邮件。试试下面的一些标题,看看有什么帮助。

$to = $_POST['EM']; // this is your Email address
$subject = "Recipt ";
$message = "The following is your receipt " .$FName. "\n This email was sent too prove that this functionality is working";

$headers    = '';
$headers    = $headers."From: outgoing@emailaddress.com"."\r\n";
$headers    = $headers."Reply-To: replytomake@emailaddress.com"."\r\n";
$headers    = $headers."Content-Type: text/html; charset=ISO-8859-1\r\n";

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

注意:某些主机上的外发电子邮件地址必须是现有的。

【讨论】:

    猜你喜欢
    • 2015-09-27
    • 1970-01-01
    • 2012-01-10
    • 2011-08-19
    • 2014-03-16
    • 2013-10-17
    • 1970-01-01
    • 1970-01-01
    • 2016-12-07
    相关资源
    最近更新 更多