{{tag>mail raspberrypi}} ====== Send mail from raspberrypi using Gmail====== 1. Turn on [[https://myaccount.google.com/signinoptions/two-step-verification|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 ====== * [[wiki:configure_exim4_bypass_local_mail_delivery|Configure exim4 to bypass local mail delivery]] * [[wiki:send_test_email_server|Send test email from server]] * [[wiki:raspberry_pi_set_static_ip|Raspberry Pi set static ip]] ====== References ====== * https://forums.raspberrypi.com/viewtopic.php?f=28&t=244147 * https://wiki.archlinux.org/title/msmtp