View Full Version : [ubuntu] Postfix- call web service after receive of mail
December 3rd, 2012, 02:50 PM
I have postfix installed in ubuntu. I want postfix/any other way(please suggest) to call the web service and provide the email in text format to that.
FYI: the web service contains the code to read the keywords in email and reply to that mail accordingly(so the headers must also be sent to the webservice)
what can i do? please help:confused:
December 3rd, 2012, 03:47 PM
You'd need to provide us with a lot more details about what you're trying to do. "Web service" is pretty meaningless.
In the meantime I suggest you look into procmail (http://www.procmail.org/); it may be what you're looking for.
December 4th, 2012, 05:51 AM
The question is not what webservice will do, what I want is, whenever i get a mail, that mail's body and a sender id must be sent as a parameters in the http request.
for ex: I want postfix/something to call http://firstname.lastname@example.org
So the mail body and sender id must be inserted whenver the mail comes.
These are my requirements
March 6th, 2013, 09:51 AM
Did you find a solution for this in the end?
March 6th, 2013, 02:10 PM
As I suggested, I'd use procmail for something like this. You can write a procmail "recipe" to hand messages to a script. In the script he could build the HTTP request and invoke something like wget.
March 8th, 2013, 04:05 AM
Certainly sounds like procmail can do the job. Personally, for low volume, I'd most likely use Mandrill (http://www.mandrill.com/), from the folks behind MailChimp (http://www.mailchimp.com/). It supports email to webhook, and is free for up to 12k emails per month. The hardest part is probably reliably parsing out the various header values you want, like subject and sender's address, which procmail won't do for you by the sounds of it.
March 8th, 2013, 06:00 PM
No, procmail is simply rules-based delivery agent. Any parsing would have to take place in the script to which procmail pipes the message.
However invoking a web request with a GET may run into all sorts of problems. Some web servers have length limits on GET query strings, so he'd probably have to have the script use a POST. He would also have to use URL-encoding or something like base64 to handle messages with special characters, attachments, and the like.
I'm putting the finishing touches on a PHP script to rewrite messages after being invoked by procmail. I'm using the mailparse (http://php.net/manual/en/book.mailparse.php) libraries for PHP though it meant having to compile my own copy of the command-line client since mailparse is not a standard extension. If I knew perl, I'd probably use that instead.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.