Wednesday, October 07, 2020

Mail from Command Line on Raspbian

The following instructions are the minimum steps required to enable sending email on Raspbian using Postfix and Gmail as the SMTP relay.

Enable "Less Secure Apps" in your Google account.

Google Account -> Security -> Less secure app access -> Turn on access -> Off

Setup Raspbian

apt install mailutils postfix libsasl2-modules

When the Postfix Configuration dialog box comes up, select Internet Site.

Update /etc/postfix/main.cf with the following lines.

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:username@gmail.com:password
smtp_sasl_security_options =
smtp_tls_security_level = encrypt

Restart the Postfix service.

service postfix restart

Send some email.

echo Hello | mail username@gmail.com

No comments: