User Tools

Site Tools


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
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
port           587

from          root@raspi-buster
password       your-gmail-account-password

# Default
account default : gmail

4. Test

echo 'message' | mail -s "raspi-buster"

Tested on

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

See also


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