我想在我的邮件服务器(在Debian上运行Postfix / Dovecot)上收到一封新邮件时执行备份脚本(.sh)。 我在这个主题上发现了很多post,但没有人给我一个工作的解决scheme。 这里我testing的最后一个解决scheme: https : //stackoverflow.com/questions/27230324/run-script-when-postfix-dovecot-get-new-mail 。 有没有人有build议?
编辑:当我收到一个新的邮件,我想运行一个bash脚本,让后缀/ dovecot把这个新的邮件在〜/ Maildir文件夹。 我正在寻找一种不会阻碍标准进程的“中间件”
如果您的实际问题是如何保留邮件服务器收到(和发送)的每条消息的备份,则答案是设置always_bcc选项并指定一个邮箱。
根据您的设置,您可以将该邮箱(或别名)收到的邮件转发给脚本进行进一步处理。
例如在/ etc / aliases中 :
mailbox: "| /usr/local/bin/script.pl"
根据评论编辑 :
相当老派,但是当你的电子邮件用户是系统用户并且拥有主目录时,还有旧的sendmail风格的.forward文件,仍然由postfix支持 。 语法有点神秘,但是~mailuser/.forward以下内容的邮件用户~mailuser/.forward都将邮件传递给用户邮件存储并将其转发给脚本:
\mailbox, "| /usr/local/bin/script.pl"
可能是,你需要postfix milter ?
您可以使用smtpd_milters参数指定仅适用于SMTP的Milter应用程序(可以有多个应用程序)。 每个Milter应用程序都由其监听套接字的名称来标识; 其他Milterconfiguration选项将在后面的章节中讨论。 Milter应用程序按照指定的顺序应用,而拒绝命令的第一个Milter应用程序将覆盖来自其他Milter应用程序的响应。
/etc/postfix/main.cf: # Milters for mail that arrives via the smtpd(8) server. # See below for socket address syntax. smtpd_milters = inet:localhost:portnumber ...other filters...
侦听套接字的一般语法如下:
unix:pathname Connect to the local UNIX-domain server that is bound to the specified pathname. If the smtpd(8) or cleanup(8) process runs chrooted, an absolute pathname is interpreted relative to the Postfix queue directory. inet:host:port Connect to the specified TCP port on the specified local or remote host. The host and port can be specified in numeric or symbolic form. NOTE: Postfix syntax differs from Milter syntax which has the form inet:port@host.
使用unix:pathname