Results 1 to 7 of 7

Thread: Postfix- call web service after receive of mail

  1. #1
    Join Date
    Dec 2012
    Beans
    2

    Angry Postfix- call web service after receive of mail

    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

  2. #2
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: Postfix- call web service after receive of mail

    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; it may be what you're looking for.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  3. #3
    Join Date
    Dec 2012
    Beans
    2

    Re: Postfix- call web service after receive of mail

    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://example.org/xyz.aspx?body=mai...id=adc@pqr.com
    So the mail body and sender id must be inserted whenver the mail comes.
    These are my requirements
    Last edited by geturnithin; December 4th, 2012 at 06:27 AM.

  4. #4
    Join Date
    Sep 2007
    Location
    Nomadic
    Beans
    197
    Distro
    Ubuntu

    Re: Postfix- call web service after receive of mail

    Did you find a solution for this in the end?
    Love & joy - Callum

  5. #5
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: Postfix- call web service after receive of mail

    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.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  6. #6
    Join Date
    Sep 2007
    Location
    Nomadic
    Beans
    197
    Distro
    Ubuntu

    Re: Postfix- call web service after receive of mail

    Certainly sounds like procmail can do the job. Personally, for low volume, I'd most likely use Mandrill, from the folks behind MailChimp. 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.
    Love & joy - Callum

  7. #7
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: Postfix- call web service after receive of mail

    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 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.
    Last edited by SeijiSensei; March 8th, 2013 at 06:06 PM.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •