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: your_email@yourisp.com
- hostname: output of
hostname -f
, for instance server-home.example.org - sender server:mail.example.com
- sender user:abcd (may be the same or different as the sender email)
- sender email:abcd@example.com, 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.
root=your_email@yourisp.com
# 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.example.com
# Where will the mail seem to come from?
rewriteDomain=example.com
# The full hostname
hostname=server-home.example.org
# 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=NO
# Use SSL/TLS before starting negotiation
UseTLS=Yes
UseSTARTTLS=Yes
# Username/Password
AuthUser=abcd
AuthPass=beith6Ei
FromLineOverride=no
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.
root:abcd@example.com
www-data:abcd@example.com
testing
sendmail
is a little bit laborious to use, but here we go:
sendmail root
ENTER
hello
ENTER
ENTER
CTRL+D
You should receive an email at abcd@example.com, otherwise have a look a /var/log/mail.*
~~~
Question, remark, bug? Don't hesitate to contact me or report a bug.