Postfix SMTP Delegation

Sat 23 December 2017 by Thejaswi Puthraya

Email still continues to be a popular communication and collaboration tool especially within enterprises. And Postfix (configurable SMTP server) has withstood the test of time and remains popular.

Programmable SMTP servers like Haraka, Lamson make building applications on top of email easy but I am not comfortable exposing them as the primary server. In comes SMTP delegation; Postfix forwards mails over to Haraka which then process the mails based on javascript (user-configured) rules.

Postfix needs to be made aware of the domains whose mails are to be delegated. This is achieved through the virtual_mailbox_domains setting in the main.cf configuration file.

Then in the transport configuration file, you need to list out the domains and the locations where the mails have to be delegated/forwarded.

Here's an snippet of a main.cf config file with the relevant change:

virtual_mailbox_domains = domain1.com domain2.com

And the transport file forwarding the emails to Haraka running on port 2525:

domain1.com     smtp:127.0.0.1:2525
domain2.com     smtp:127.0.0.1:2525

Finally, you restart postfix to reflect the changes.