RPi - postfix

Installation

sh# apt install bsd-mailx postfix

Configuration


sh# cd /etc/postfix

sh# vi main.cf


myhostname                 = rpi-1.localhost

...

relayhost                  = [smtp.mail.yahoo.com]:587

smtp_sasl_auth_enable      = yes

smtp_sasl_password_maps    = hash:/etc/postfix/sasl/user@yahoo.passwd

smtp_sasl_security_options = noanonymous

smtp_use_tls               = yes

smtp_tls_CAfile            = /etc/ssl/certs/ca-certificates.crt

smtp_generic_maps          = /etc/postfix/rewrites/satellite.from.address


sh# cd /etc/postfix

sh# mkdir rewrites && cd rewrites

sh# vi satellite.from.address

@rpi-1.localhost user@yahoo.com


sh# postmap satellite.from.address  # => generates satellite.from.address.db hashmap


sh# systemctl restart postfix

Testing

Test without rewrite rule

sh# echo "hello world 1" | mail -s "testemail 1" -r "user@yahoo.com" other.user@gmail.com

Test including rewrite rule

Sh# echo "hello world 2" | mail -s "testemail 2" other.user@gmail.com