Giter Site home page Giter Site logo

email_via_crontab's Introduction

Setting ssmtp for sending email via crontab


ssmtp

sudo apt-get update sudo apt-get install ssmtp

Making a backup copy and editing

sudo cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf-0 sudo nano /etc/ssmtp/ssmtp.conf

Edit it to the following state

[email protected]
[email protected]
AuthPass=pass
FromLineOverride=YES
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES

Check

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:

mutt

Install the mail client on your ubuntu server: sudo apt-get install mutt

Send e-mail

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.

Open the file /etc/ssmtp/revaliases

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!

Finally, run

cat fileWithEmailInIt.txt | sendmail -i -t

then wait a few seconds (10-30) and check your email!

crontab -e

[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

If have some problem...

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.

email_via_crontab's People

Watchers

Oleg avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.