- We will start with a trusty DigitalOcean instructional – at least step 1 of that instructional.
- I want to send mail using mailgun, which allows for ports 25, 587 and 465 (SSL/TLS). I’ll use 587 which is called submission in postfix terminology, I guess due to 587 being the proper port for TLS email submission. Because I want to use encryption (SASL) (or whatever), I need to setup Postfix accordingly. I changed my Postfix config file as such
ubuntu@machine_name:~$ sudo nano /etc/postfix/main.cf
#various stuff above relayhost = [smtp.mailgun.org]:submission mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 20000000 recipient_delimiter = + inet_interfaces = all inet_protocols = all smtp_sasl_auth_enable = yes smtp_tls_security_level = encrypt smtp_sasl_security_options=noanonymous smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
Some of these settings are related to the DigitalOcean instructional, such as custom mailbox_size_limit. Make sure all the smtp settings are there
- Then I want to enter in my SMTP login details:
ubuntu@machine_name:~$ sudo nano /etc/postfix/sasl_passwd
– maintaining the important requirements shown in the link in part 2.
- hash the file for postfix:
ubuntu@machine_name:~$ sudo postmap /etc/postfix/sasl_passwd
- change the password file permissions:
ubuntu@machine_name:~$ sudo chmod 770 “/etc/postfix/sasl_passwd”
The file should already have: sudo chown root:root “/etc/postfix/sasl_passwd”
- I changed some of the TLS settings in the config as talked about here.. (note sure of the relevance)
# TLS parameters #smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem #smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key smtpd_use_tls=yes
- I went to step 3 of the DigitalOcean instructional, sent email and checked the log (at “/var/log/syslog”).. I don’t really like the email sender, despite setting myorigin (myorigin = /etc/mailname etc) and myhostname in the config, which leads to here (step 7). Although I couldn’t use echo and had to change the settings with nano.
- So I sent an email using step 3 of DigitalOcean instructional again, and it looks nicer (using mailgun as the MTA and MDA – since mail forwarding on my domain provider is crappy).
One of the number of awesome things about mailgun is that I can send mail from a different sender than the one authenticating via SMTP.. a really sweet feature.
- As in step 5, I created: sudo nano /etc/postfix/generic
ubuntu@internal-IP.internal-domain ubuntu@domain @internal-IP.internal-domain @domain @internal-IP @domain #use 'postmap /etc/postfix/generic' to hash this file #then 'service postfix restart'
I added the second line which happily caught mail for postmaster as in step 4 of the DigitalOcean instructional.
Add this to the config
smtp_generic_maps = hash:/etc/postfix/generic
- Reading the comments in the DigitalOcean instructional it seems many are having trouble with their step 4, I fixed this by commenting out
mydestination = mydomain.com localhost
and adding simply
#mydestination = mydomain.com localhost mydestination = localhost
It seems the aliases settings are basically ignored since we aren’t using the local address class…
- restart postfix
sudo service postfix restart