SMTP Server to Deliver All Mail to User@localhost – Setup Guide

mailsmtp

I'd like to configure an SMTP MTA to accept all mail addressed to any domain and deliver it to my local user account.

It would be very useful for debugging mail sent in some code I'm working on. I'll be running the server locally – no outside world interaction required.

To be clear:

user@gmail.com -> delivered to -> cam8001@localhost

dogs@live.com -> delivered to -> cam8001@localhost

anything@any.domain.co.uk -> delivered to -> cam8001@localhost

Best Answer

I found this article explaining how to do it with postfix.

The key is:

luser_relay = cam8001@localhost
local_recipient_maps =

as explained in the article:

luser_relay is the local user on the machine to catch all email that does not belong to an existing local user. luser_relay documentation.

local_recipient_maps is left blank to stop Postfix from checking if the user exists on the local machine. This is very important, without this line, Postfix will still reject the mail and send a bounce message.

After adding the above two lines to the configuration, apply the changes and restart Postfix.

Related Question