Skip to content

Instantly share code, notes, and snippets.

@justinmklam
Created August 26, 2020 22:11
Show Gist options
  • Save justinmklam/b5ace727e498d6e9564c32cde26f60db to your computer and use it in GitHub Desktop.
Save justinmklam/b5ace727e498d6e9564c32cde26f60db to your computer and use it in GitHub Desktop.
Set up email from a linux server

Source: https://help.ubuntu.com/community/EmailAlerts

Prerequisites

Install the ssmtp package

sudo apt-get install ssmtp

Configure SSMTP

Edit the configuration file. The lines without the # are the ones we are interested in.

sudo nano /etc/ssmtp/ssmtp.conf

Adjust and add as necessary to match the following parameters

Change "MyEmailAddress" and "MyPassword" to your own.

# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
#root=postmaster
[email protected]

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
#mailhub=mail
mailhub=smtp.gmail.com:587

[email protected]
AuthPass=MyPassword
UseTLS=YES
UseSTARTTLS=YES

# Where will the mail seem to come from?
#rewriteDomain=
rewriteDomain=gmail.com

# The full hostname
#hostname=MyMediaServer.home
hostname=MyMediaServer.home

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES

Check Setup

Lets test that our ssmtp setup was correct by sending an Email

echo "Test message from Linux server using ssmtp" | sudo ssmtp -vvv [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment