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 have a postfix mail server (on example.com) and if I send a mail to alert@example.com I want to check the content of the mail, add some extra info and resend it somewhere else, (sms gateway email or so..)

Is something like that possible with postfix? thanks.

share|improve this question
    
Check out procmail –  Warner Mar 29 '10 at 13:38

2 Answers 2

up vote 0 down vote accepted

Or you couyld make alert@example.com an alias to a script,

you could put into /etc/alias something like

alert@example.com:     "|/usr/local/myscript.pl"

and create a script that parses Standard input using: MIME::Parser, Email::Simple and your favourite perl modules... or any other language of your choice... The script could then email the result, call any sms web gateway, etc...

share|improve this answer

Yeah, you could do it with Postfix. Essentially you want to put any messages to alert@example.com into a quarantine for processing which would be essentially putting it into the HOLD queue in postfix for processing.

There is probably a better lookup table to use, but, you could test with header_checks postfix file. /etc/postfix/header_checks - You could make this check for TO: alert@example.com and send to HOLD queue (note... there is probably faster/better lookup table for this)

If you read the comments in the header_checks file for HOLD it says...

#               Arrange  for  the  message to be placed on the hold
#               queue, and inspect the next input line.   The  mes-
#               sage  remains  on hold until someone either deletes
#               it or releases it for delivery.
...
#               Mail that is placed on hold can  be  examined  with
#               the  postcat(1)  command,  and  can be destroyed or
#               released with the postsuper(1) command.
# 
#               Note: use "postsuper -r" to release mail  that  was
#               kept  on  hold for a significant fraction of $maxi-
#               mal_queue_lifetime  or  $bounce_queue_lifetime,  or
#               longer.

Would mean logging in and manually checking the emails in the hold queue by command line, but, pretty much what you want?

share|improve this answer

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.