Local-only delivery SMTP server

When you have a development server - a virtual machine or even a spare laptop - you eventually run into problem of email delivery because your application needs to send emails for whatever reason. Due to well known email spam problems the internet service provides typically no longer allow users to send email using unauthenticated SMTP connections.

I have a virtual machine running on my Fedora laptop where I write some test applications, and I travel from network to network every day so I cannot configure any outbound SMTP connections without exposing my SMTP credentials - which are btw. usually same as the IMAP credentials - to a configuration file of e.g. Postfix.

Local-only delivery to the rescue!

I've configure the virtual machine to forward all emails to my laptop, and told my laptop to deliver all email to a single local mailbox. Simple and efective. As additional bonus my crappy applications won't accidentally send spam our other unwanted emails to innocent bystanders...

On the virtual machine add this line to /etc/postfix/main.cf:

 relayhost =

If for some reason your physical host (laptop) has other bridge IP address you might want to adjust the IP...

On the physical host add these lines (don't forget to change the username) to /etc/postfix/main.cf:

 luser_relay = twillber@localhost
 local_recipient_maps =
 mydestination = pcre:/etc/postfix/localdeliverydestinations

On the physical host add this line to /etc/postfix/localdeliverydestinations:

 /.*/         ACCEPT

Restart your Postfixes and you should be ready to go!

No comments:

Post a Comment