User Tools

Site Tools


wiki:send_mail_raspberrypi

Send mail from raspberrypi using Gmail

1. Turn on 2-factor authentication in Google and generate the app password which will be used by the pi.

2. Install packages:

sudo apt-get install msmtp msmtp-mta mailutils

3. Put the following in /etc/msmtprc

# Generics
defaults
auth           on
tls            on
# following is different from ssmtp:
tls_trust_file /etc/ssl/certs/ca-certificates.crt
# user specific log location, otherwise use /var/log/msmtp.log, however, 
# this will create an access violation if you are user pi, and have not changes the access rights
logfile        ~/.msmtp.log

# Gmail specifics
account        gmail
host           smtp.gmail.com
port           587

from          root@raspi-buster
user           your-gmail-accountname@gmail.com
password       your-gmail-account-password

# Default
account default : gmail

4. Test

echo 'message' | mail -s "raspi-buster" destination-email-address@gmail.com

Tested on

  • Rasbperry Pi 3B+
  • Raspbian GNU/Linux 10 (buster)

See also

References

wiki/send_mail_raspberrypi.txt · Last modified: 2023/12/26 18:52 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki