My Lab server needs to be able to send emails now. I’ve done some digging about, and have decided that I will configure Postfix to do forward things to my email hosting provider instead of exim4.
Obviously, this required a bit more thumping this time, as I’ve never used Postfix before.
Annoyingly, the default that Debian sets up results in warning being generated in log files, which means you have to manually tune the main.cf file to make the warning go away and then I could configure it to forward to my email host.
These initial changes involve me adding the following:
default_cache_db_type = lmdb
default_database_type = lmdb
And then changing the following to refer to lmdb:
alias_maps
alias_database
smtp_tls_session_cache_database
With appropriate runs of postmap and postalias.
Remember to delete the old .db files that Postfix will have created initially.
Having completed this, I added the configuration to talk to my mail hosts server. This has come from the following sites:
This largely now consists of:
relayhost = [<fq hostname>]:<port>
# SASL authentication for the relay
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = lmdb:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
Create the /etc/postfix/sasl_passwd file. The template for that is:
[<fq hostname>]:<port> <username>:<password>
Then fix the file permission to be rw only to the root user. Update the database version of the password file:
postmap /etc/postfix/sasl_passwd
And then restart Postfix:
postfix reload
Using sudo as required for both these commands.
Then test you can send an email:
sendmail <test address> <<EOF
Subject: Test Email Send
Email Content Line 1
Email Content Line 2
EOF
Hopefully, if you look in the /var/log/mail.log you should be able to see an email being sent.
The Postfix configure is complete if the log is correct and you receive the email.
