News:

The Latest electronic and computer Tips that work!

Main Menu

Send Gmail Mail from Application

Started by branx86, September 19, 2018, 07:20:35 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

branx86

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.