首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用php邮寄怎么用呢?

用php邮寄怎么用呢?
EN

Stack Overflow用户
提问于 2011-05-14 04:43:14
回答 2查看 1.7K关注 0票数 1

如何在php中使用mail by header?

这是我现在使用的:

代码语言:javascript
复制
//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显示我正在尝试更改的内容!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-05-28 01:30:06

您要做的是在邮件()函数中添加第五个参数,它需要使用"-f“sendmail选项。

例如:

代码语言:javascript
复制
mail($to, $subject, $body, $headers, "-fsender@domain.com");

发送带有最后一个参数的邮件会将信封发件人更改为"sender@domain.com“。大多数时候,像gmail这样的电子邮件提供商甚至不会显示手动设置的地址(我想这是你想要的)。

有关更多详细信息,请参阅http://us2.php.net/function.mail

票数 0
EN

Stack Overflow用户

发布于 2011-05-14 04:56:09

你是说X-Mailer吗?

代码语言:javascript
复制
$headers = "From: test@gmail.com\r\nReply-To:test@gmail.com\r\nX-Mailer: PHP/" . phpversion();
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5997560

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档