ssmtp notes /usr/sbin/ssmtp is where it lives /etc/ssmtp/ssmtp.conf is config file with user/auth for gmail https://stackoverflow.com/questions/38391412/raspberry-pi-send-mail-from-command-line-using-gmail-smtp-server accepted I use this method on my Raspberry Pi 3 devices: Google account setting Login to your gmail account Go to: Settings -> Accounts and Import -> Other Google Account settings Go to: Personal info & privacy -> Account overview Go to: Sign-in & security -> Connect apps & sites Set option Allow less secure apps to ON Install SSMTP sudo apt-get install ssmtp Save original conf file sudo mv /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.bak Create new conf file (with vi, or some other text editor) sudo vi /etc/ssmtp/ssmtp.conf file content root=your_account@gmail.com mailhub=smtp.gmail.com:587 FromLineOverride=YES AuthUser=your_account@gmail.com AuthPass=your_password UseSTARTTLS=YES UseTLS=YES # Debug=Yes Secure conf file sudo groupadd ssmtp sudo chown :ssmtp /etc/ssmtp/ssmtp.conf If you have error on this step like ''cannot access'' ... you must find ssmtp file and use that path: sudo find / -name "ssmtp" sudo chown :ssmtp /usr/sbin/ssmtp sudo chmod 640 /etc/ssmtp/ssmtp.conf sudo chmod g+s /usr/sbin/ssmtp Sending mail from (only one) command line echo "This is a test" | ssmtp recipient.address@some_domain.com or printf "To: recipient.address@some_domain.com\nFrom: RaspberryPi3\nSubject: Testing send mail from Raspberry\n\nThis is test. Best Regards!\n" | ssmtp -t Sending mail from file test.txt Make file with similar content: To: recipient.address@some_domain.com From: your_account@gmail.com Subject: Testing send mail from Raspberry This is test mail (body) Best Regards! Now you can send mail from file ssmtp recipient.address@some_domain.com < test.txt //////////////////////////// Using the printf form of the command line with double quotes (as shown) results in the error: -bash: !\n: event not found Use single quotes around the whole line (between printf and | ) instead, and it works. – tim11g Sep 27 '17 at 20:15 This method of setting up your Gmail account is now superceded by the App Passwords process as described here: support.google.com/accounts/answer/185833 – Martin KS Dec 24 '17 at 21:55