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

how to configure postfix to send local mail to another local server?

· 52CE 我爱测

I have a pair of mail servers that are comprised mainly of Postfix, Procmail and Cyrus-IMAP and they both work fine. The IMAP servers are configured in a simple master/replica pair. All 'normal' mail is accepted by the master's P…

问题原文

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

I have a pair of mail servers that are comprised mainly of Postfix, Procmail and Cyrus-IMAP and they both work fine. The IMAP servers are configured in a simple master/replica pair. All 'normal' mail is accepted by the master's Postfix which processes it through Procmail for delivery to the Cyrus-IMAP running on the same server. Both servers are capable of running like this but only the master actually receives external email.

At present, local accounts on either box send mail (for example, generated by cron jobs) through its local Postfix which is delivered locally to the Cyrus-IMAP on the same box.

However, Cyrus's replication doesn't like changes happening directly on the replica so I would prefer for the replica to deliver its local mail to be delivered to the master.

I see two ways of achieving this:

  • change the replica's local transport to deliver mail to Postfix on the master server

or

  • change the replica's procmail to deliver mail to Cyrus-IMAP on the master server.

There is a third way which is for the replica server to relay everything to the master server (i.e. both internal and external emails) but that seems somewhat unnecessary. I don't need to change how external mail is handled - it's ok for either box to send external email via its local Postfix which then relays it externally.

What I really would like to do is just change how internal emails are processed on the replica so that it delivers them to the master, either into Postfix or into the IMAP server there.

Existing, working, configuration of my local transport in postfix's master.cf:

procmail-local  unix  -       n       n       -       -       pipe
    flags=OR user=cyrus argv=/usr/bin/procmail -t -m RECIPIENT=${mailbox}
    SENDER=${sender} EXTENSION=${extension} /etc/procmailrc

Existing, working, configuration of delivery to Cyrus in procmailrc:

DELIVERMAIL="/usr/lib/cyrus/bin/deliver -r $SENDER -a $RECIPIENT $RECIPIENT

已采纳解答

原帖链接 · Jenny D · CC BY-SA 4.0

I'd do it earlier still - by removing your domain name from mydestination, mail for that domain should be delivered to the server listed as MX for your domain. If you want to specify a server, as opposed to using the MX, you should use the file /path/to/postfix/etc/transport for this. That file should then look like this:

# all mails to our own domain should go to our main incoming server
ourdomain.com    smtp:[mainserver.ourdomain.com]

Please note that the [] marks are important - without them, your server will still lookup the MX record for mainserver.ourdomain.com.

After editing the file, use the command postmap /path/to/postfix/etc/transport

You also need to make sure that postfix knows to use that file, by editing /path/to/postfix/etc/main.cf with the following line:

transport_maps = hash:/path/to/postfix/etc/transport

if your system uses db files. If instead it uses dbm files, the line should be

transport_maps = dbm:/path/to/postfix/etc/transport

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

资料来源与适用范围

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

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

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