sudo apt-get update sudo apt-get install ssmtp
sudo cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf-0 sudo nano /etc/ssmtp/ssmtp.conf
[email protected]
[email protected]
AuthPass=pass
FromLineOverride=YES
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES
Next, if google mail will be used, you must go to https://www.google.com/settings/security/lesssecureapps and allow the use of insecure applications:
Install the mail client on your ubuntu server: sudo apt-get install mutt
After the installation is finished, try to send the mail:
mutt -s "test mail" [email protected] < /dev/null
And check the mail you sent the letter to? It should already be there.
and add the line:
[yourPCUsername]:[[email protected]]:smtp.mail.yahoo.com:587
That's it, you're good to go! To test, the easiest way (IMO) is to create a file with the following in it:
and add the line:
To: [email protected]
From: "whateverYaWant" <[email protected]>
Subject: Some Notifying Email
MIME-Version: 1.0
Content-Type: text/plain
Body of your email goes here! Hello world!
cat fileWithEmailInIt.txt | sendmail -i -t
then wait a few seconds (10-30) and check your email!
[email protected]
00 16 * * 1,2,3,4,5 /home/scripts/loop_off_servers.sh
00 6 * * 1,2,3,4,5 /home/scripts/loop_on_servers.sh
Sending mail via commandline worked fine, but no mail was sent through crontab. Fixed it by changing FromLineOverride
to NO in /etc/ssmtp/ssmtp.conf
. During debugging, it was also helpful to add Debug=YES
to ssmtp.conf
- it resulted in more detailed information being logged to /var/log/mail.log
.