更改PHP邮件功能中的返回路径 [英] Change the Return-Path in PHP mail function
本文介绍了更改PHP邮件功能中的返回路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可以通过PHP的mail()函数发送电子邮件中的Return-Path值吗?
Is it possible to change the Return-Path value in emails are sending via mail() function of PHP ?
我在我的网站发送的电子邮件中的值为'www-data@mydomain.com',并导致电子邮件传送失败过程中的一些问题。我想将其设置为我的电子邮件地址。
It's value is 'www-data@mydomain.com' in emails I send in my site and it causes some problems on email delivery failed process. I want to set it to my email address.
以下是我尝试过的代码:
Here's the code I have tried:
$headers = 'MIME-Version: 1.0' . "\n";
$headers .= "Content-type: text/html; charset=utf-8" . "\n";
$headers .= "Return-Path: <adminemail@yahoo.com>"."\n";
$headers .= "Errors-To: <adminemail@yahoo.com>"."\n";
// Additional headers
$headers .= "To: email1@yahoo.com <adminemail@yahoo.com>" . "\n";
$headers .= "From: adminemail@yahoo.com <adminemail@yahoo.com>" . "\n";
// Mail it
mail('email1@yahoo.com', 'test', 'salam', $headers, "f");
推荐答案
您可以设置回复&返回路径到标题如下
You can set reply to & return path into headers as below
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'Return-Path: webmaster@example.com' . "\r\n" .
OR
作为调整返回路径的第五个参数
OR as the fifth parameter to adjust the return path
mail($to, $subject, $message, $headers, "-f email@wherever.com");
其中email@wherever.com应该由您的邮件取代。
where email@wherever.com should be replaced by your mail.
这篇关于更改PHP邮件功能中的返回路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文