User Tools

Site Tools


setting_up_smtp_smarthost

Setting up a Postfix cloud-based SMTP smarthost for incoming and outgoing email

OK, so first of all. I installed Postfix:

   sudo apt-get install postfix

Incoming email

After that, I edited the /etc/postfix/main.cf file to add the following:

   smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
   myhostname = pluto.example.com
   #alias_maps = hash:/etc/aliases
   #alias_database = hash:/etc/aliases
   myorigin = /etc/mailname
   mydestination =
   relayhost =
   mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
   mailbox_size_limit = 0
   recipient_delimiter = +
   inet_interfaces = all
   inet_protocols = all
   local_recipient_maps =
   local_transport = error:local mail delivery is disabled
   virtual_alias_maps = hash:/etc/postfix/virtual
   relay_domains = example1.com, example2.com
   parent_domain_matches_subdomains = debug_peer_list smtpd_access_maps
   relay_recipient_maps =
   transport_maps = hash:/etc/postfix/transport

What this part did was allow me to specify aliases and destinations for my incoming email

Next stage was to create /etc/postfix/virtual and add some aliases:

   sudo nano /etc/postfix/virtual
   postmaster	        postmaster@example1.com, postmaster@example2.com
   abuse		abuse@example1.com, abuse@example2.com
   steve		my.aliases@example1.com, my.aliases@example2.com

After this, I need to tell Postfix where to deliver emails:

   sudo nano /etc/postfix/transport

Add the following:

   example1.com       smtp:[destination.example.com]:587
   example2.com	smtp:[destination.example.com]:587

After, issue the following 3 commands:

   sudo postmap /etc/postfix/transport
   sudo postmap /etc/postfix/virtual
   sudo postfix reload

At this stage, emails that come in will be delivered to their destination server. No Anti-Spam is active at this point, but you should be able to change your MX records to this host now.

setting_up_smtp_smarthost.txt · Last modified: 2017/03/22 23:19 (external edit)