Loading ...
Sorry, an error occurred while loading the content.

Hook script execution before message has been accepted with code 220?

Expand Messages
  • Peter Bauer
    Hello, I would like that Postfix calls my PHP script before it accepts a message with code 220. So smtpd would get the message, once the sender has sent the
    Message 1 of 2 , May 24 4:56 AM
    • 0 Attachment
      Hello,

      I would like that Postfix calls my PHP script before it accepts a message with code 220.
      So smtpd would get the message, once the sender has sent the command DATA and ., it should then call my PHP script.
      The script will parse the email content with header and body, so some thing, and if it exits with exit code 0, then smtpd should respond with:
      220 OK
      other exit codes like 1 should produce 550, 2 450 etc.

      Additionally, after the PHP script has been executed, postfix has no more to queue the mail or do other processings.

      You may ask why I'm not writing directly a SMTP daemon in PHP? Its because I don't want to code the complete socket handling and all SMTP protocol options.

      Is there a way to create this hook before the message has been accepted?
      --
      Best regards,
      Peter Bauer
      Linux & UNIX developper
    • Wietse Venema
      ... Postfix has two ways to hook into the live message stream: http://www.postfix.org/SMTPD_PROXY_README.html This is SMTP-based, but Postfix does the hard
      Message 2 of 2 , May 24 5:21 AM
      • 0 Attachment
        Peter Bauer:
        > Hello,
        >
        > I would like that Postfix calls my PHP script before it accepts a
        > message with code 220. So smtpd would get the message, once the
        > sender has sent the command DATA and ., it should then call my PHP
        > script. The script will parse the email content with header and
        > body, so some thing, and if it exits with exit code 0, then smtpd
        > should respond with: 220 OK other exit codes like 1 should produce
        > 550, 2 450 etc.

        Postfix has two ways to hook into the "live" message stream:

        http://www.postfix.org/SMTPD_PROXY_README.html
        This is SMTP-based, but Postfix does the hard work for you.

        http://www.postfix.org/MILTER_README.html
        This uses a different protocol.

        It's unlikely that a third hook will be added any time soon.

        Wietse

        > Additionally, after the PHP script has been executed, postfix has
        > no more to queue the mail or do other processings.
        >
        > You may ask why I'm not writing directly a SMTP daemon in PHP? Its
        > because I don't want to code the complete socket handling and all
        > SMTP protocol options.
        >
        > Is there a way to create this hook before the message has been
        > accepted? -- Best regards, Peter Bauer Linux & UNIX developper
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.