Low memory usage SMTP Send-Only

mikhomikho AdministratorOG

Written by @mikho, 1 May 2021
Article was migrated from WordPress to Vanilla in March 2022

image

In the LowEndSpirit, we tend to look for resource-efficient alternatives. Here is an alternative to use instead of Postfix, Sendmail, or Exim.

Often when installing and running a web application or script you need an SMTP server to send an email, rarely there is the need to receive any email. It works equally well using ssmtp, which also is simple and fast to install. It takes two minutes to install and configure.

RedHat, CentOS7, Fedora

yum install ssmtp

If you receive a “Package ssmtp is not available” error, you’ll need to install EPEL on your machine with the following command:

yum --enablerepo=extras install epel-release

Once done, you’ll be able to install ssmtp using the above command.

Ubuntu, Debian

apt-get install ssmtp

The configuration is done in the /etc/ssmtp/ssmtp.conf and there is only a couple of settings to change:

Mailhub
The mail server you must send mail through (relay). In this guide we will use GMail smtp Server.
From Line Override
Set to YES to allow the use of others choose from addresses other than the system itself.
AuthUser
The username or email adress on the account used to login to gmail.
AuthPass
The password for above account
UseSTARTTLS
Set to Yes to use TLS when connecting to the SMTP server.

## Config file for sSMTP sendmail
## The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster
# 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=smtp.gmail.com:587
[email protected]
AuthPass=YourtopSecretPassw0rd!
UseSTARTTLS=YES 
# Where will the mail seem to come from?
#rewriteDomain= 
# The full hostname
hostname=debianVPS.local 
# 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: 
addressFromLineOverride=YES

No reboots required.

To use ssmtp with the PHP mail() function, you have to edit the sendmail_path parameter in php.ini to something like this:

sendmail_path = /usr/sbin/ssmtp -t

You have no open ports, everything just works!

“Technology is best when it brings people together.” – Matt Mullenweg

Comments

  • Thanks for the post! Where are the log files stored?

  • mikhomikho AdministratorOG

    @StuderSolutions said:
    Thanks for the post! Where are the log files stored?

    sSMTP has debug logging built in. In your ssmtp.conf file, include the following line: Debug=YES

    When debug logging is active, the entire contents of emails sent via sSMTP, including headers, is logged to syslog.

    Thanked by (3)ehab AaronSS vimalware

    “Technology is best when it brings people together.” – Matt Mullenweg

  • edited May 2021

    Thanks!

  • Thanks! Didn't know this existed, hence I never bothered to setup mail alerting on servers because I didn't want to spin up a Postfix instance etc etc.

    Thanked by (2)mikho AaronSS
Sign In or Register to comment.