Sending email from the server

Sending email from the server

ubuntu 18.04 hw2018 sendmail server

A server should be able to send email alerts, just in case some service like cron, mdadm or smartmontools detect a failure.

sudo apt-get install ssmtp

Here is the simplest configuration

The simplest way to let a server send emails is by using ssmtp, here is a sample configuration for it, using an external SMTP server.

This configuration supposes you’ve got a stmp username, servername, password, and email for sending mails plus an email for receiving emails for instance:

  • recipent:
  • hostname: output of hostname -f, for instance
  • sender
  • sender user:abcd (may be the same or different as the sender email)
  • sender, the part after the @ goes to rewriteDomain
  • sender passwd:beith6Ei

Edit /etc/ssmtp/ssmtp.conf

# Config file for sSMTP sendmail
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.

# The place where the mail goes. The actual machine name is required no 
# MX records are consulted. Commonly mailhosts are named

# Where will the mail seem to come from?
# The full hostname

# 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
# Use SSL/TLS before starting negotiation

# Username/Password


and /etc/ssmtp/revaliases

# sSMTP aliases
# Format: local_account:outgoing_address:mailhub
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.


sendmail is a little bit laborious to use, but here we go:

sendmail root




You should receive an email at, otherwise have a look a /var/log/mail.*


Question, remark, bug? Don't hesitate to contact me or report a bug.