如何将一些电子邮件路由到 Postfix 中的脚本?

Nic*_*gan 8 email postfix regex

如何将所有定向到 user-*@example.com(即 user-1234@example.com)的电子邮件路由到 Postfix 中的管道命令?这个想法是通过为每个用户分配动态电子邮件别名来创建 craigslist 风格的匿名化。但是,我似乎无法在文档中找到相关信息。

mai*_*ilq 10

好的。现在采用不同的方法。

放入一个新的传输master.cf

coolscript unix -    n    n    -    50    pipe
    flags=R user=vmail argv=/path/to/script -o SENDER=${sender} -m USER=${user} EXTENSION=${extension}
Run Code Online (Sandbox Code Playgroud)

您可以根据需要扩展/修改参数。

然后(为了消除 pcre)您可以使用 regexp 来执行以下操作main.cf

transport_maps = regexp:/etc/postfix/redirect.regexp
Run Code Online (Sandbox Code Playgroud)

而在/etc/postfix/redirect.regexp你把:

/^user-.*@example\.com/   coolscript:
Run Code Online (Sandbox Code Playgroud)

使用postfix reload.

  • @ChristopherThomas 你没有逃脱 example.com 中的点?! (2认同)

mai*_*ilq 5

首先检查您是否已将 pcre 编译到 Posfix 中postconf -m。然后你可以设置main.cf

virtual_alias_maps = pcre:/etc/postfix/redirect.pcre
Run Code Online (Sandbox Code Playgroud)

并在/etc/postfix/redirect.pcre你输入:

/^user-.*@example\.com$/   somelocalalias
Run Code Online (Sandbox Code Playgroud)

并在/etc/aliases你添加

somelocalalias: |"/path/to/script"
Run Code Online (Sandbox Code Playgroud)

不要忘记postalias /etc/aliases然后使用 重新加载 Postfix postfix reload