{"id":119,"date":"2016-04-30T21:11:12","date_gmt":"2016-05-01T02:11:12","guid":{"rendered":"https:\/\/servertricks.com\/?p=119"},"modified":"2016-04-30T22:03:45","modified_gmt":"2016-05-01T03:03:45","slug":"email-notifications-with-ssmtp","status":"publish","type":"post","link":"https:\/\/servertricks.com\/index.php\/2016\/04\/30\/email-notifications-with-ssmtp\/","title":{"rendered":"Email Notifications with sSMTP"},"content":{"rendered":"<p>Start by install ssmtp<\/p>\n<p><code>$ sudo apt-get install ssmtp<\/code><\/p>\n<p>Next modify \/etc\/ssmtp\/ssmtp.conf file with the following:<\/p>\n<pre>\r\n# Config file for sSMTP sendmail\r\n#\r\n# The person who gets all mail for userids < 1000\r\n# Make this empty to disable rewriting.\r\nroot=*YOUREMAIL*@gmail.com\r\n\r\n# The place where the mail goes. The actual machine name is required no\r\n# MX records are consulted. Commonly mailhosts are named mail.domain.com\r\nmailhub=smtp.gmail.com:587\r\n\r\n# Where will the mail seem to come from?\r\nrewriteDomain=gmail.com\r\n\r\n# The full hostname\r\nhostname=localhost\r\n\r\n# Are users allowed to set their own From: address?\r\n# YES - Allow the user to specify their own From: address\r\n# NO - Use the system generated From: address\r\nUseTLS=Yes\r\nFromLineOverride=Yes\r\nUseSTARTTLS=Yes\r\nAuthUser=*YourUsername*\r\nAuthPass=*YourPassword*\r\nTLS_CA_File=\/etc\/pki\/tls\/certs\/ca-bundle.crt<\/pre>\n<p>Last step is to add a translation to the revaliases file:<\/p>\n<p><code>$ sudo su<br \/>\n$ nano \/etc\/ssmtp\/revaliases<\/code><\/p>\n<p>Add the following line to the bottom of the file (modified with your settings:<\/p>\n<pre>root:*YOUREMAIL*@gmail.com:smtp.gmail.com<\/pre>\n<p>Now send a test by running the following command:<\/p>\n<p><code>$ echo \"Test message from your linux server\" | sudo ssmtp -vvv EXAMPLE@DOMAIN.COM<\/code><\/p>\n<p>The reason I set this up was so I could implement a network monitoring script that emails me if the ping fails. If you are interested in that functionality please view the \"Setup Network Monitoring\" document on this site. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Start by install ssmtp $ sudo apt-get install ssmtp Next modify \/etc\/ssmtp\/ssmtp.conf file with the following: # Config file for sSMTP sendmail # # The person who gets all mail for userids < 1000 # Make this empty to disable rewriting. root=*YOUREMAIL*@gmail.com # The place where the mail goes. The actual machine name is required [&hellip;]\n<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[11,10],"class_list":["post-119","post","type-post","status-publish","format-standard","hentry","category-ubuntu","tag-14-04","tag-16-04"],"_links":{"self":[{"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/posts\/119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/comments?post=119"}],"version-history":[{"count":5,"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/posts\/119\/revisions"}],"predecessor-version":[{"id":124,"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/posts\/119\/revisions\/124"}],"wp:attachment":[{"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/media?parent=119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/categories?post=119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/tags?post=119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}