cBrandon Community

General Category => Linux Fixes => Topic started by: branx86 on September 19, 2018, 07:20:35 PM

Title: Send Gmail Mail from Application
Post by: branx86 on September 19, 2018, 07:20:35 PM
Installing a Mail Client

For this solution you'll need a throwaway Gmail account, as you are going to specify your Gmail password in a configuration file.

Start by installing the tools you'll be using to send emails:

sudo apt-get install ssmtp
sudo apt-get install mailutils
sudo apt-get install mpack

Next, run:

sudo nano /etc/ssmtp/ssmtp.conf

and ensure that file contains the following configuration parameters, making sure that  your Gmail account credentials are in place:

root=postmaster
mailhub=smtp.gmail.com:587
hostname=raspberrypi
AuthUser=yourgmailusername@gmail.com
AuthPass=yourgmailpassword
FromLineOverride=YES
UseSTARTTLS=YES

Finally send a test email with an attachment from the target_dir directory:

mpack -s "Test Email" [target_dir/filename] [recipientEmailAddress]

If this mail arrives you are good to go to the next step.