大网数据广告活动
服务器运维问答

configure postfix to catch all email for all domain and forward to local user

· 52CE 我爱测

I'd like to configure Postfix (on Ubuntu) to catch all email for all domain and store them locally. I'd use it for testing. The application under test sends emails to random addresses ([email omitted], [email omitted], and so on)…

问题原文

原帖链接 · riskop · CC BY-SA 3.0

I'd like to configure Postfix (on Ubuntu) to catch all email for all domain and store them locally.

I'd use it for testing. The application under test sends emails to random addresses ([email omitted], [email omitted], and so on), and I'd like to check these emails locally (thunderbird).

I already now that the following in main.cf forwards anyuser@mydestination to localuser:

local_recipient_maps=
luser_relay = localuser

But I'd like to forward anyuser@anydomain to localuser too.

What is the simplest Postfix configuration for this?

Thank you!

已采纳解答

原帖链接 · riskop · CC BY-SA 3.0

I've found another configuration which works: specifying "mydestination" as a regexp table which accepts any domain.

Main.cf:

local_recipient_maps=
luser_relay = riskop
mydestination = regexp:/etc/postfix/match_all_destination_re

match_all_destination_re (// matches everything, result is irrelevant):

// this_can_be_anything

I consider this solution more straightforward than Esa's "Overriding Postfix's built-in default transport:nexthop" solution.

Note that instead of the "regexp" table format you can use perl-compatible "pcre" format table also. That may result better performance (which is absolutely no concern in my use case). In that case, however you need pcre support in Postfix. The config in this case:

Main.cf:

local_recipient_maps=
luser_relay = riskop
mydestination = pcre:/etc/postfix/match_all_destination_re

match_all_destination_pcre (// matches everything, result is irrelevant):

// this_can_be_anything

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-04-28)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。