在 CakePHP 和 Postfix 中处理电子邮件退回
我正在尝试处理退回的消息并将其发送给负责的系统管理员。
我使用 CakePHP 电子邮件组件来发送消息。在服务器端,我使用 postfix 来传输消息。
function sendAsEmail($data) {
$Email->sendAs = 'html';
$Email->from = $user['Sender']['username'] . '@example.com';
$Email->return = Configure::read('App.systemAdminEmail');
$Email->bcc = array($data['Message']['recipient_text']);
$content = 'Some content';
$Email->send($content);
}
正如您在上面看到的,我将 $Email->return 设置为系统管理员的电子邮件,它将发送所有退回的消息。
在后缀配置中,我尝试创建一个ounce.cf模板并设置bounce_template_file。 http://www.howtoforge.com/configure-custom-postfix-bounce- messages
如何获取退回的消息并将其发送给系统管理员?
I'm trying to handle bounced message and send to a responsible System Administrator.
I use CakePHP Email Component to send the message. On server side, I use postfix to transport the message.
function sendAsEmail($data) {
$Email->sendAs = 'html';
$Email->from = $user['Sender']['username'] . '@example.com';
$Email->return = Configure::read('App.systemAdminEmail');
$Email->bcc = array($data['Message']['recipient_text']);
$content = 'Some content';
$Email->send($content);
}
As you can see above, I set the $Email->return to sysadmin's email which it will send all the bounced message.
On postfix configuration, I tried creating a bounce.cf template and set bounce_template_file. http://www.howtoforge.com/configure-custom-postfix-bounce-messages
How do I get the bounced message and send it to System Administrator?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您需要做的是使用 PHP 的 SMTP(或者我认为是 POP3)连接器。然后,您基本上必须创建自己的 PHP 电子邮件客户端,该客户端将登录到服务器,询问已退回的邮件,并适当地解析它们。
我认为应该有一个 CakePHP 组件可以实现这一点,但我找不到。
我建议您在电子邮件中使用信封标题。否则,您将在尝试解析收件人服务器退回邮件时陷入困境,而这些是非常不一致的。如果您使用 VERP(可变信封返回协议?)标头,您可以将唯一的哈希编码到电子邮件地址中,这应该很容易在 PHPEmailClient 中解析出来。
有关 VERP 的更多信息:http://en.wikipedia.org/wiki/Variable_envelope_return_path
Cake-具体的VERP内容: http://www. mainelydesign.com/blog/view/setting-envelope-from-header-cakephp-email-component
我还强烈建议您考虑使用 SwiftMailer。它有很多插件;您可能会找到一个基本的 PHP SMTP 客户端,您可以轻松修改它来执行您需要的操作。 http://swiftmailer.org/
I think what you'll need to do is to use an SMTP (or I suppose POP3) connector for PHP. Then you'll basically have to create your own PHP email client that will login to the server, ask for the messages that have been bounced, and parse them appropriately.
I would think there would be a CakePHP component for this, but I can't find one.
I would recommend that you use an Envelope Header in your email. Otherwise you'll be stuck trying to parse the recipient server bounce, and those are very very inconsistent. If you use the VERP (variable envelope return protocol?) header, you can encode a unique hash into the email address which should be really easy to parse out in your PHPEmailClient.
More info on VERP: http://en.wikipedia.org/wiki/Variable_envelope_return_path
Cake-specific VERP stuff: http://www.mainelydesign.com/blog/view/setting-envelope-from-header-cakephp-email-component
I also highly recommend that you look into using SwiftMailer. It has a lot of plugins; you might find a base PHP SMTP client that you can easily modify to do what you need. http://swiftmailer.org/