What do you use as a lightweight SMTP for outgoing e-mails only?

I am running an app that sends e-mails via SMTP when events occur once in a while, and I don't need a fully featured e-mail server.

EDIT: I am more than happy to use something like postfix (and do), if that's the best choice. I was thinking there may be something much simpler, that runs out the box.

  • I think it is perfectly reasonable to stick with something like exim and postfix. They aren't hard to configure if you are doing simple things. – Faheem Mitha May 7 '13 at 19:16
  • What's your definition of "lightweight"? How large are you expecting the messages to be? How often is "once in a while"? – Mike B Feb 6 '15 at 19:45

There are several choices of minimal, relay-only mail transfer agents (MTAs, or "mail servers"), some of which have been mentioned in other answers:

For either of those to work, you need a full fledged MTA somewhere that will further relay your messages (known as "mail hub") and it is strongly recommended that you control this mail hub. Bad Things™ can happen otherwise.

  • esmtp is no longer being maintained. – Nikola Kotur Aug 6 '13 at 7:56
  • 1
    nullmailer has a serious SMTP compliance problem : it retries infinitely when given an SMTP permanent error. This can cost you real money if you pay for bandwidth/transit bugs.debian.org/cgi-bin/bugreport.cgi?bug=329192 – telent Feb 6 '14 at 16:13
  • @telent: you should not use nullmailer in such a scenario. – user601 Feb 7 '14 at 12:09
  • Thanks! The config guide at troubleshooters.com/linux/nullmailer notes a security issue with nullmailer: it exposes passwords on the command line, or at least used to do that. Other conversations note that mstmp makes it a bit less clear how to enqueue mail than nullmailer. – nealmcb Jun 12 '19 at 3:35

IMHO, the easiest way to do this is with postfix. You can configure it as a light outgoing relay with these commands:

postconf -e relayhost=other.mailserver.com
postconf -e myorigin=my.domainname.com

As long as the SMTP server specified in relayhost doesn't require authentication, allows you to relay or is a valid destination for the recipient address this will work.

The myorigin parameter will be the default domain name. So if you send mail to foo it will go to foo@my.domainname.com. Mail sent by user bar will be from bar@my.domainname.com.

If you do need to authenticate and want to support TLS, also run the following commands:

postconf -e smtp_tls_security_level=may
postconf -e smtp_sasl_auth_enable=yes
postconf -e smtp_sasl_password_maps=pcre:/etc/postfix/sasl_password_maps

Then in /etc/postfix/sasl_password_maps have this content:

/./ username:password

All mail will be sent to your relayhost with the specified username and password.

  • Tried these settings and I get an error: "error: unsupported dictionary type: pcre" – valentt Nov 6 '15 at 11:37
  • 1
    Install pcre and/or postfix-pcre and try again. – bahamat Nov 7 '15 at 6:48
  • I figured it out, also in the mean time, there were two packages missing, first one is postfix-pcre as you said, but other one was a strange one - libsasl2-modules. I'm puzzled how libsasl2 and libsasl2-modules-db were installed but libsasl2-modules was missing... Now finally everything works. Can you please add this crucial info to your answer? – valentt Nov 9 '15 at 11:39
  • 1
    For tls, I also used: relayhost=other.mailserver.com:465 then smtp_tls_wrappermode=yes and smtp_tls_security_level=encrypt but it's attempting to use the local user as the auth. I have to rewrite the auth user somehow. – tu-Reinstate Monica-dor duh Jun 29 '16 at 4:13
  • "As long as the SMTP server specified in relayhost doesn't require authentication" -> ok, but that's rarely the case nowadays. Your suggestion is correct, but mostly irrelevant! – FarO Jun 12 '19 at 9:16

Assuming you need a program you can run from the shell like sendmail(8), perhaps MSMTP will fit your needs? It can connect to a remote SMTP server and submit mail it gets as stdin, just like sendmail.

  • I use MSMTP for this, works great and the configuration is very simple. – dsp Sep 1 '10 at 15:16
  • I'm so glad you recommended this. I've been looking for something like that for quite a while now. sendmail's configuration is just way too differentiated for my needs. – ixtmixilix Sep 3 '10 at 20:33

ESMTP is a relay only mail transfer server that may work for your application.

  • 1
    project seems dead as of 2009 – SHernandez Jul 4 '15 at 15:08

You may find sSMTP suitable for your needs. Read this article on it and its limitations.

Honestly though, I wouldn't be too stressed about installing postfix or exim, even if it is only for sending emails.

  • 1
    +1 for ssmtp, -1 for the unnecessary comment at sendmail, as well as recommending using a full mta, which is way harder to do right. badly configured and maintained mail servers make the life of us mail admins hell. – user601 Sep 1 '10 at 11:27
  • @hop: I disagree on both counts. sendmail is awful. Also, exim for example is the Debian default, and is perfectly simple to use. So is postfix, probably, but I have never used it. – Faheem Mitha May 7 '13 at 19:14

If you use docker, https://hub.docker.com/r/zixia/simple-mail-forwarder/ is a good choice for easy deploy and only of 10MB size, with full smtp(tls) support.


You technically don't need an e-mail server on your host, what you need (and probably already have) is an smtp-client (or MUA) that can connect to your corporate SMTP Server (which could be anywhere you can connect to.)

Depending on the App (and the programming language it was written in) there are many different ways for your app to connect to the 'the' SMTP Server on your network.

Usually, with PHP or Python, there's a configuration file with the app to specify the "SMTP" Server (which can be on your host or elsewhere on your network.) If you already have a mail server on the network, then just point the configuration to that server.

If no other options exist, the app can generate the e-mail message to standard output that you can process with something like:

listoftargets="me@example.com jab@example.com" echo "Test Content" | mail -s "Test Subject" $listoftargets

On some systems, there is already a minimal mailserver for sending only.

Sam T.

  • I have a whole bunch of servers in the cloud, and I really wanted each to have their own outgoing SMTP servers, rather than rely on anything external. In that way, if my remote SMTP server is down, it's not effecting every server. – FlappySocks Sep 1 '10 at 10:09
  • 1) if you let PHP or Python do the smtp part, you have to do all the work (queueing, error handling) that an MTA would handle. 2) at the end you contradict what you say in the beginning – user601 Sep 1 '10 at 11:16
  • Some linux applications are setup to expect mail or sendmail named executables. System notifications. That's the whole point isn't it? For anything else there are no constraints. – Craig Hicks Jul 14 '18 at 22:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.