使用PHP发送邮件更改发件人地址? [英] Send mails with PHP change From Address?
本文介绍了使用PHP发送邮件更改发件人地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用PHP发送消息时,收件人会收到一个类似这样的发件人地址:
When I send a message with PHP the recipients gets a from address such as this one:
user123@p3nlhg147.shr.prod.phx3.secureserver.net
如何使用我的自定义电子邮件地址,例如 info@mydomain.com
作为发件人地址?
How can I use my custom email address like info@mydomain.com
as sender address?
推荐答案
邮件功能的一部分是
您应该发送一个From头,例如:
You should send a From header, like so:
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
来源: http://php.net/manual/en/function.mail.php
这篇关于使用PHP发送邮件更改发件人地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文