如何在php中使用mail by header?
这是我现在使用的:
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: test@gmail.com\r\nReply-To:test@gmail.com";
//send the email
$to = "test@gmail.com";
$subject = "This is a subject";
$body = "Hi there!";
if (mail($to, $subject, $body,$headers))
{
echo("\nMessages successfully sent!");
} else {
echo("\nMessages delivery failed...");
}当我点击show details时,我在我的gmail上看到了这样的信息:
from test@gmail.com reply-to testreply@gmail.com to test@gmail.com date,2011年5月14日上午12:06主题stefanos neofitidis!你评论了你的诗:Tree present mailed-by ip-1-1-1-1.ip.secrevever.net
我不想让ip-1-1-1-1.ip.secReserver.net向users...this显示我正在尝试更改的内容!
发布于 2011-05-28 01:30:06
您要做的是在邮件()函数中添加第五个参数,它需要使用"-f“sendmail选项。
例如:
mail($to, $subject, $body, $headers, "-fsender@domain.com");发送带有最后一个参数的邮件会将信封发件人更改为"sender@domain.com“。大多数时候,像gmail这样的电子邮件提供商甚至不会显示手动设置的地址(我想这是你想要的)。
有关更多详细信息,请参阅http://us2.php.net/function.mail。
发布于 2011-05-14 04:56:09
你是说X-Mailer吗?
$headers = "From: test@gmail.com\r\nReply-To:test@gmail.com\r\nX-Mailer: PHP/" . phpversion();https://stackoverflow.com/questions/5997560
复制相似问题