Saturday, August 15, 2020

postfix for raspi info

 I just installed Postfix on multiple raspis to be informed about updates, problems etc.

Any suggestions on how this could be done easier by e.g. collecting would be very much appreciated.


I started of with:

sudo apt install postfix:

  • Setup as satellite machine
  • Hostname unchanged
  • Relay or smarthost: put in your smtp
  • Everythin else default.

After that I've updated my /etc/aliases to reroute everything towards root and then towards my external mail adress:

postmaster:    root
nagios: root
root: admin@yourdomain.com


in the postfix Config file: /etc/postfix/main.cf I added:



smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
sender_canonical_maps = hash:/etc/postfix/sender_canonical
smtp_tls_security_level = encrypt


The  meaning of sender_canonical  is not clear as it seems redundant to the aliases:
www-data admin@yourdomain.com
root admin@yourdomain.com


the sasl_password file needs the input of your external relay or smarthost:

smtpserver:25  user:password


Be sure, the file ist only readable by its owner.


now:

sudo newalias    --> gets the aliases updated
 sudo postmap hash:/etc/postfix/sasl_password  && sudo postmap /etc/postfix/sender_canonical --> gets the files merged into postfix
sudo systemctl restart postfix -->  start with new config

If everything works you should be able to do this:
echo Hello!  Test! | mail -s Testmail admin@yourdomain.com



If it does not work due to the encryption or auth because missing Mech:
https://serverfault.com/questions/1008119/postfix-error-sasl-authentication-failed-cannot-authenticate-to-server-no-mec
try to install:
apt install libsasl2-modules


No comments:

Post a Comment