You can't install local mail server on dynamic address and set it for direct delivery to target domains. That worked fine fifteen years ago, but not any longer, because of antispam measures employed by target servers. You would have to set it to forward all mail to some "real" server where you have an account. And when you do that, you don't need anything as complex as full mail server.
You can either use some DIY "talk to mail server directly" method (your links #1 and #3) for individual things or use system-wide method (e.g. msmtp mentioned in link #2). Many programs use sendmail for sending mail and msmtp (msmtp-mta package for Raspbian) can pretend to be exactly that. So you configure it once and it will work for many programs without additional configuration (it will make e.g. php's mail() function work).
Example configuration file /etc/msmtprc:
Code: Select all
defaults
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
#tls_certcheck off
syslog LOG_MAIL
account default
host smtp.example.net
from youraccount@example.net
auth on
user yourlogin
password yourpassword
You might need to block tls_trust_file and unblock tls_certcheck if target server doesn't have valid certificate. All logs will go nicely to /var/log/mail.* files. And if you do it system-wide like this, don't give accounts on your RasPi to untrusted strangers, because they too could use sendmail with this account.