Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
1  
So this means I can't suggest using postfix 'cause it's awesome? –  xenoterracide Sep 1 '10 at 0:58
    
I removed the linux tag because I'm pretty sure that's not relevant ( I think all smtp servers that work on unix work on all unices )... but I could be wrong. –  xenoterracide Sep 1 '10 at 1:01
    
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

6 Answers 6

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

postconf -e relayhost=other.mailserver.com
postconf -e mailname=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 mailname 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.

share|improve this answer

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.

share|improve this answer
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. –  hop 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

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.

share|improve this answer
    
esmtp is no longer being maintained. –  Nikola Kotur Aug 6 '13 at 7:56
    
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 at 16:13
    
@telent: you should not use nullmailer in such a scenario. –  hop Feb 7 at 12:09

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.

share|improve this answer
    
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.

share|improve this answer
    
Looks like the kind of thing I am after, thanks. –  FlappySocks Sep 1 '10 at 10:15

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.

share|improve this answer
    
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 –  hop Sep 1 '10 at 11:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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