Wednesday, August 5, 2020

Forwarding ‘root’’s mail on Raspberry PI OS to gmail account

1.  Install ‘mailutils’, ‘postfix’ and ‘libsasl2-modules’ with:
sudo apt install mailutils postfix libsasl2-modules
2.  Edit “/etc/postfix/main.cf”
Change the line that reads “inet_interfaces = all” to “net_interfaces = loopback-only”
Change the line that reads “relayhost = “ to “relayhost = [smtp.gmail.com]:587”
  Add the lines:
smtp_use_tls = yes
  smtp_sasl_auth_enable = yes
  smtp_sasl_security_options =
  smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
3.  Create the file “/etc/postfix/sasl/sasl_passwd” to enable authentication 
add the line “[smtp.gmail.com]:587    username@gmail.com:password”
The user address I use is an email account that I created especially for my computers to use as a ‘from’ address
4.  Run “sudo postmap /etc/postfix/sasl/sasl_passwd”
5.  Run “sudo systemctl restart postfix”
6.  To forward mail sent to ‘root’ I need to edit the ”/etc/aliases” file
sudo nano /etc/aliases 
add  “root: youremail@yourdomain.com” below the “postmaster:  root”  line.
7. Update the system’s aliases with “sudo newaliases”

No comments:

Post a Comment