让 postfix 使用 always_bcc 触发 php 脚本

让 postfix 使用 always_bcc 触发 php 脚本

我一直对此感到非常困难,到处都搜索过,最后在极度绝望的情况下发布了这个问题。

我在 ubuntu 12.04 上使用 postfix 和 dovecot。我努力触发一个 php 脚本,该脚本在服务器收到新电子邮件时运行。在我的 /etc/postfix/main.cf 中,我添加了以下行:

always_bcc = new_incoming_email@localhost

在 /etc/aliases 中我有以下行:

new_incoming_email: "|/usr/bin/php -f /path/to/file/new_incoming_email.php"

在 /etc/postfix/vmaps 中我有以下行:

new_incoming_email@localhost localhost/new_incoming_email/

当我从命令行运行该文件时,我可以看到该文件可以正常工作,因为它会将一行添加到日志文件中作为其功能的一部分。从命令行我输入:/usr/bin/php -f /path/to/file/new_incoming_email.php

这是我向服务器发送电子邮件时在 /var/log/mail.log 中得到的内容:

Feb  1 04:20:52 myserver postfix/smtpd[3090]: connect from nm40-vm4.bullet.mail.bf1.yahoo.com[72.30.239.212]
Feb  1 04:20:52 myserver postfix/smtpd[3090]: C1EDD20630: client=nm40-vm4.bullet.mail.bf1.yahoo.com[72.30.239.212]
Feb  1 04:20:52 myserver postfix/cleanup[3004]: C1EDD20630: message-id=<[email protected]>
Feb  1 04:20:52 myserver postfix/qmgr[1092]: C1EDD20630: from=<[email protected]>, size=24383, nrcpt=2 (queue active)
Feb  1 04:20:52 myserver postfix/error[3008]: C1EDD20630: to=<[email protected]>, relay=none, delay=0.22, delays=0.18/0/0/0.04, dsn=4.4.1, status=defferred (delivery temporarilyferred (delivery temporarily suspended: connect to localhost.com[74.125.224.72]:25: Connection timed out) suspended: connect to localhost.com[74.125.224.72]:25: Connection timed out)
Feb  1 04:20:52 myserver postfix/virtual[3092]: C1EDD20630: to=<[email protected]>, relay=virtual, delay=0.22, delays=0.18/0.01/0/0.03, dsn=2.0.0, status=sent (delivered to maildir)
Feb  1 04:20:53 myserver postfix/smtpd[3090]: disconnect from nm40-vm4.bullet.mail.bf1.yahoo.com[72.30.239.212]

其中 example.com 是我的服务器中存在的域。

以下是“postconf -n:”的输出

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
always_bcc = new_incoming_email@localhost
biff = no
config_directory = /etc/postfix
default_privs = johnvision
default_transport = smtp
home_mailbox = Maildir/
inet_interfaces = all
inet_protocols = all
mailbox_size_limit = 0
mydestination = localhost
mynetworks = 127.0.0.0/8 [::1]/128 108.171.187.9
myorigin = $myhostname
recipient_delimiter = +
smtp_host_lookup = native
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu/GNU)
virtual_gid_maps = static:5000
virtual_mailbox_base = /home/vmail
virtual_mailbox_domains = /etc/postfix/vhosts
virtual_mailbox_maps = hash:/etc/postfix/vmaps
virtual_minimum_uid = 1000
virtual_uid_maps = static:5000

我已经尝试让它工作了很长时间。实际上,我之前确实让它工作了一段时间,但我在服务器上做了一些改动(不确定是什么),从那时起它就一直无法工作。

我确实需要一些帮助。

答案1

根据您的邮件日志,我可以看到 postfixalways_bcc从 new_incoming_email@ 重写目标本地主机至 new_incoming_email@本地主机. 这导致 postfix 出现错误

(delivery temporarily deferred (delivery temporarily suspended: connect to localhost.com[74.125.224.72]:25: Connection timed out)

负责这次重写的参数是附加点_mydomain,默认值为是的. 当值为是的,postfix 会将字符串附加.$mydomain到没有“.domain”信息的地址。这就是为什么new_incoming_email 脚本永远不会被触发。

解决方案

普京append_dot_mydomain = no主配置文件应该使 postfix 不会像以前一样改变域名。

相关内容