使用postfix将通配符电子邮件redirect到一封电子邮件

我正在创build一个反弹电子邮件系统,邮件可以回复我的网站上的消息。

但是,当电子邮件发送给包含上一条消息的用户时,“ Reply-To字段包含一个类似于此的电子邮件[email protected] (其末尾包含ID)。

如果用户回复,则回复消息将被发送回[email protected] ,当然,除了[email protected]之外,它没有自己的邮箱。

如何将所有传入的消息从特定的通配符notification-message-*@mysite.comredirect到[email protected] ? 我做了一些研究,但是没有luser_relay = [email protected]工作,包括luser_relay = [email protected]并把notification-message-*放在后缀别名表中, notification@有一个Maildir,所以电子邮件会进入它。

概念图:

在这里输入图像描述

我正在使用Ubuntu 11.04。

我倾向于使用recipient_delimiter来解决这个问题。

如果您不介意使用略有不同的Reply-To地址,则可以设置:

 recipient_delimiter = + 

然后发送邮件至例如[email protected] (注意+ )将被传送给notification用户(假设没有更具体的规则/用户匹配notification+message-988742 )。

可以尝试设置recipient_delimiter = - (以便您可以使用Reply-To标题,因为它们是在问题中),但我不知道如何将左侧的分隔符的多个实例工作,我没有Postfix手来检查。

正如所说的mschuett,你可以使用正则expression式

首先检查后缀是否支持正则expression式:

 root @ mail / # postconf-m | grep regexp regexp root @ mail / # 

创build文件/ etc / postfix / aliases-regexp并添加到你的正则expression式中

 root @ mail / # cat /etc/postfix/aliases-regexp /notification-message-[0-9]+@example\.net/ [email protected] root @ mail / # 

运行postmap并检查它是否工作:

 root @ mail / # postmap /etc/postfix/aliases-regexp root @ mail / # postmap -q [email protected] regexp:/etc/postfix/aliases-regexp [email protected] root @ mail / # 

如果一切正常,请将此文件添加到别名数据库

例:

 root @ mail / # cat /etc/postfix/main.cf | grep ^alias_maps alias_maps = hash:/etc/aliases regexp:/etc/postfix/aliases-regexp root @ mail / # 

如果您使用虚拟域,请将此文件添加到您的virtual_alias_maps

例:

 root @ mail / # cat /etc/postfix/main.cf | grep ^virtual_alias_maps virtual_alias_maps = mysql:/etc/postfix/mysql/alias.conf regexp:/etc/postfix/aliases-regexp root @ mail / # 

不要忘记重新启动后缀。

祝你好运!

别名地图( 虚拟 , 本地 ,…)将与regexp_table格式结合使用。 但是,如果你已经编译了PCRE,那么你也可以使用pcre_table格式。

否则,你应该search“Postfix catch-all”,这是更加贪婪的。