Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to forward *@domain.com to a script.

I know the EXIM way and the PROCMAIL way.

Is there a lighter way? Any experiences? Which one is the fastest if I JUST WANT it to delivery emails to script? (no pop accounts, nothing else)

(I knew qmail but I don't want to install "big" software that eats too many resources on the server).

share|improve this question
1  
Why not just have your MTA run the script, and forgo the MDA altogether? –  Ignacio Vazquez-Abrams Apr 15 '11 at 14:22
    
I just noticed you're scrambling things here. Procmail is an MDA (delivery agent). Exim is an MTA (transfer agent). You don't need an MDA, you just need the MTA. Your script is going to be the delivery agent. –  Caleb Apr 15 '11 at 15:00
    
Updated question with MTA in the title, since you don't need an MDA, your question is about lightweight MTAs. –  Caleb Apr 15 '11 at 15:48
    
BTW, if you search ServerFault or the Unix-SE site for "lightweight mta" you will get quite a number of people working on similar problems. –  Caleb Apr 16 '11 at 15:34
1  
Maybe it's worth considering you have the wrong technology altogether! If you are going to be receiving so many emails that are to be automatically processed by a script that it uses up server resources, perhaps you should reconsidering using email at all and just write an API for your two things to talk together. What is in these emails? Maybe we can suggest something else entirely. –  Caleb Apr 16 '11 at 15:53
show 1 more comment

4 Answers

What you are asking is really about MTAs (Mail Transfer Agents) rather than MDAs (Mail Delivery Agents). Your question includes comments about both (Procmail is an MDA, exim is an MTA).

In your case you are going to dispose of any MDA by just "delivering" to your script. In exim an alias like username: |/path/to/script is enough to get that part done with no fancy internal routing or MDA needed.

As for the MTA, Exim is actually pretty light weight. It doesn't provide pop accounts or anything else, it just handles the chat with other mail servers to accept messages, then passes them off to somebody (Usually an MDA or other mail servers).

Don't make life more complicated for yourself down the road by trying to make a non-standard setup, short circuit normal protections like the validation that MTA's run on incoming mail, etc. Just wire the right parts together. Using a pipe-alias in exim as above is a dead simple way to route mail to a script and still behave properly as an MTA.

share|improve this answer
    
I don't need pop accounts, nor SMTP ... nothing but listening to emails from *@domain.com and redirect everything to a PHP script. That domain.com will not have accounts, or need to send anything. Just listening ! any super light mda ? –  user75317 Apr 16 '11 at 2:07
    
@user75317 Please let us help define your problem, not just answer the one you have in your head. YOu DO need SMTP, that is the protocol that mail servers use to talk to each other and you need to talk in order to "listen to emails" that come in. I realize you don't need pop accounts, exim does NOT PROVIDE pop. That would take some other people of software and nobody here is recommending anything that provides it. –  Caleb Apr 16 '11 at 7:46
    
I know there's software to accomplish this. But I've been testing exim and qmail and they eat too many resources. I need the host in a high level performance, so I can not install software happily. So, I would need a way to have a simple daemon listening to mail protocol and receiving all emails from a domain name (*@mydomain.com), and forward all the mail to a script. netcat would not answer to standard mail protocol communications. AFAIK, I need a script listening and handling the HELO, RCPT TO, etc ... from external SMTP sending emails to my host. –  user75317 Apr 16 '11 at 17:27
add comment

Do you really want the script to just run, regardless of what is passed to it? Or do you want proper SMTP handling?

The lightest way might be to use something like Python's Twisted library listening for SMTP or a node.js SMTP server script, and have it fire of a script on each message required. That way you get full multi-threading, without much of anything else in the way.

I would say though that Exim and the others like it will be more than fast enough for 99% of uses.

share|improve this answer
    
I'm not looking just to be fast, but to be the lighter way. I do not want to compromise performance of the host. I do not need POP accounts, SMTP ... nothing but to listen to *@domain.com forwarding all of that to a PHP script. –  user75317 Apr 16 '11 at 2:05
    
Firing up a PHP shell for each email received is going to have significantly larger impact on resources than exim or anything else. PHP is not a lightweight solution, the PHP processor is a significant hit. I think you need to re-frame your problem and possibly redesign your solution. Exim can send and receive millions of emails per day. –  Ewan Leith Apr 18 '11 at 14:48
add comment

If you can spare port 25 on a unique IP what about using netcat to listen on port 25 ? That's truly zero load and install. A wrapper script to restart it after a reboot/fail should be easy too.

share|improve this answer
    
Sounds cool !!! But, do you know any script to start with ? I mean, I'm not going to start from scratch and RFC documents to see how to listen properly to mail from other servers :P –  user75317 Apr 16 '11 at 2:06
    
I found this one : sourceforge.net/projects/fdm –  user75317 Apr 16 '11 at 4:02
    
It's really easy netcat -l 25 > /tmp/filename. Loads on examples on the web, one here: http://h.ackack.net/cheat-sheets/netcat –  Jonathan Ross Apr 16 '11 at 5:27
    
when somebody tries to send an email it won't work ! I change the MX records to the IP of the host, and then what ? the script needs to hear from a standard mail connection protocol ... the HELO, and all stuff ... –  user75317 Apr 16 '11 at 15:20
    
Netcat will basically grab anything sent to port 25 ... anything ! –  Jonathan Ross Apr 16 '11 at 16:01
show 15 more comments

If you just want to recieve E-Mails you can use a "server" like http://code.google.com/p/subethasmtp/ .

You can have a 1 file java program using this library that will accept all emails and execute some code for it. The problem with it is you will need to have java present on the machine.

share|improve this answer
    
Hmmm ... I can't install java in the server ... but thank you, I'm trying to find some similar project in Perl or C. –  user75317 Apr 17 '11 at 11:56
add comment

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.