当我添加标题信息时,我在发送电子邮件时有问题。然而,当我只是删除头参数它的工作原理。怎么了?是代码吗?或者我需要在web服务器管理面板上更改一些设置,说"允许- headers"或其他什么?我正试图发送到hotmail,以防这对确定问题有任何关系。任何帮助都将非常感激。谢谢。
下面不发送电子邮件:
<?php
$to = 'iputmyrealemailhere@hotmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com';
mail($to, $subject, $message, $headers);
?>
下面发送电子邮件:
<?php
$to = 'iputmyrealemailhere@hotmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com';
mail($to, $subject, $message);
?>
我在我的php邮件功能中使用这些头,它工作得很好。注意:我还使用第三方邮件路由服务来避免我的邮件被标记为来自垃圾邮件IP。你可能也想调查一下。
$headers = 'From: '.$from.'@foo.net' . "'r'n" .
'Reply-To: '.$from.'@foo.net' . "'r'n" .
'X-Mailer: PHP/' . phpversion() . "'r'n" .
'MIME-Version: 1.0' . "'r'n" .
'Content-type: text/html; charset=iso-8859-1' . "'r'n";
我还使用mail()
的第五个可选参数来设置信封地址,例如:
$parameters = '-f '.$from.'@foo.net';
所以最后的调用是:
mail($to, $subject, $message, $headers, $parameters);
你可以直接从标题列表中删除"FROM:"。但真正的问题是如何将发送邮箱地址改为我想要的邮箱地址