I did it with sSMTP as this is a way simpler/smaller than a fully blown postfix setup. (way fewer things to get wrong). Note that this config would only allow for mails outgoing from the machine you are installing it on. it does not suppoer delivery of incoming emails.
This is really a matter for maximum 5min to setup.
For sake of example the following assumptions are true in the below example config:
- we are sending mail to a local machine in the same network using ip-address on port 2525
- we are not using encryption or authentication
you can get more details from the man-page, or use google to help you with specific configs (search for: ssnmp+mail+to+gmail
)
quick example:
# sudo -i
# apt-get update && apt-get install ssmtp
# nano /etc/ssmtp/ssmtp.conf
Add the following that would fit your environment:
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=some_email@domain.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=192.168.2.88:2525
# Where will the mail seem to come from?
#rewriteDomain=
# The full hostname
hostname=hostname.domain
# 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
test:
# ssmtp some_email@domain.com
To: some_other_email@domain.com
From: some_email@domain.com
Subject: test email
[enter]
my testing 1,2,3
[ctrl-d]
Added food for thought
I use this to forward the email to a local Docker instance that is converting my email to a Telegram chat message and deliver this in my Telegram group where I bring all my system alerts together from my home automation system to SMNP alerts, and also as per above system emails for local alerts/warnings. Though this is prolly useless to 90% of you reading this, it might remember you all that outgoing system emails might just be the first step of the delivery chain and more can be had from this :)
Enjoy
echo "Test mail thingy" | mail -s "Test Postfix Subject" rmortensen84@gmail.com
– Rene Mortensen Jan 25 '19 at 16:03/var/log/mail.log
for why the send failed. If it says SSL authentication failed you might have to go to this URL to authorize your "device" https://www.google.com/accounts/DisplayUnlockCaptcha – Kristopher Ives Jan 25 '19 at 17:56/etc/ssl/certs
doesn't contain the certificate for Gmail, although I'm not certain why, but I have read you may also need to setsmtpd_tls_CApath
which I have added to the config example in this answer. – Kristopher Ives Jan 25 '19 at 17:58systemctl reload postfix
. – Eric Fossum Mar 06 '23 at 18:27