使用 PHP 通过 SMTP 发送邮件时使用 Return-path

发布于 2024-12-10 07:39:04 字数 242 浏览 6 评论 0原文

使用 PHP 通过已验证 SMTP 发送邮件时,有没有办法设置返回路径? 我希望退回邮件能够被“发件人”地址以外的其他电子邮件地址捕获。

我知道有一种方法可以使用“普通”PHP mail() 函数(通过在第 5 个参数中设置“-f”标志)来执行此操作,但我不知道如何使用 SMTP 进行管理。

还尝试了 PEAR 的 Mail-package,但在标头中设置 Return-path 并没有完成这项工作。

Is there a way to set the Return-path when sending mail through authenticated SMTP using PHP?
I want bounce mails to be caught by another e-mail address than the "from" address.

I know that there is a way to do this with the "normal" PHP mail() function (by setting the "-f" flag in the 5th parameter), but I have no clue how to manage this with SMTP.

Also tried PEAR's Mail-package, but setting Return-path in the headers didn't do the job.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

攒眉千度 2024-12-17 07:39:04

将第四个 mail() 参数 (additional_headers) 设置为 "Return-path:[电子邮件受保护]"

示例:

$to     = "[email protected]";
$from       = "[email protected]";
$bounce     = "[email protected]";
$subj       = "mysubject";
$message    = "blah";

$headers    = "From:$from\r\nReturn-path:$bounce"

mail($to, $subj, $message, $headers);

您可以看到使用 \r\n(换行符)分隔多个 additional_headers

另请参阅:http://php.net/manual/en/function.mail.php< /a>

Set the fourth mail()-parameter (additional_headers) to "Return-path:[email protected]".

Example:

$to     = "[email protected]";
$from       = "[email protected]";
$bounce     = "[email protected]";
$subj       = "mysubject";
$message    = "blah";

$headers    = "From:$from\r\nReturn-path:$bounce"

mail($to, $subj, $message, $headers);

You can see that you separate multiple additional_headers with \r\n (newlines).

See also: http://php.net/manual/en/function.mail.php

葬心 2024-12-17 07:39:04

这就是你需要做的。

您需要将标头中的“返回路径”设置为要用作退回电子邮件的电子邮件。这对我有用。

例如 :

$headers['From']    = '[email protected]';
$headers['To']      = '[email protected]';
$headers['Subject'] = 'Test message';
$headers['Return-Path'] = '[email protected]';

Here's what you need to do.

You need to set 'Return-Path' in the Headers to the email you want to use as your bounce email. This worked for me.

For example :

$headers['From']    = '[email protected]';
$headers['To']      = '[email protected]';
$headers['Subject'] = 'Test message';
$headers['Return-Path'] = '[email protected]';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文