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

Use/transform SMTP session data into an header - more than only the e-mailadresses

Expand Messages
  • Alex
    Hi folks, Situation: Hoping to tie Postfix into a chain of software and hardware appliances as a Message Bus, most of which is outside of my control. Postfix
    Message 1 of 4 , Jul 22, 2014
    • 0 Attachment
      Hi folks,

      Situation:
      Hoping to tie Postfix into a chain of software and hardware appliances
      as a Message Bus, most of which is outside of my control. Postfix is run
      inside a heavily firewalled network, no e-mail incoming from the outside
      world.

      I'm trying to find out how (much work it is) to transform/convert the
      RCPT TO line--*including* the NOTIFY section--from the incoming SMTP
      session with an e-mail, into a mailheader with Postfix (or
      milter-plugin) *and* strip the NOTIFY section from the SMTP session
      after the original notify_options are preserved for the mailheader. The
      notify wish of the sender (software program/appliance) would be picked
      up from the header and handled at a later step. These e-mails will be
      stored in a Maildir folder, no further relay via SMTP.

      - Before, SMTP session:
      RCPT TO: <mailbox@domain> NOTIFY=notify_options


      - After, SMTP session:
      RCPT TO: <mailbox@domain>

      After, desired result as a line in the e-mail:
      X-env-recipient: <mailbox@domain> NOTIFY=notify_options


      I've found http://www.postfix.org/postconf.5.html#smtpd_command_filter -
      the section of the example (/etc/postfix/command_filter) seems
      sufficient to strip the NOTIFY part from the RCPT TO line. However I
      don't see any indication that it is possible to write a mailheader line
      with the information from the NOTIFY part. (If it is possible to use
      PREPEND here, it would end up in the SMTP session, not in a header is my
      guess?)

      Also found an example to use the smtpd_recipient_restrictions setting
      with a pcre table:
      /(.*)/ prepend X-Envelope-To: <$1>
      but that doesn't seem to offer the option to use anything from the
      NOTIFY section of the SMTP session.


      Anyone know if it is possible what I outlined above, directly with a
      (combination of) Postfix setting(s)/pcre statement(s)? And if so, can
      provide me with a hint in the right direction?

      And otherwise, might a Before-Queue milter-plugin work or is there no
      access to the NOTIFY part of the SMTP session possible for that either
      with Postfix?


      If there's no option at all to do this with Postfix, there's a pretty
      good chance I'll be asked with which mailserver it would be possible,
      which'd be a shame since so far Postfix has performed fine.

      Kind regards,

      Alex
    • Wietse Venema
      ... Converting SMTP command line options into message headers requires an SMTP-based filter, for example, smtpd_proxy_filter. See:
      Message 2 of 4 , Jul 22, 2014
      • 0 Attachment
        Alex:
        > Hi folks,
        >
        > Situation:
        > Hoping to tie Postfix into a chain of software and hardware appliances
        > as a Message Bus, most of which is outside of my control. Postfix is run
        > inside a heavily firewalled network, no e-mail incoming from the outside
        > world.
        >
        > I'm trying to find out how (much work it is) to transform/convert the
        > RCPT TO line--*including* the NOTIFY section--from the incoming SMTP
        > session with an e-mail, into a mailheader with Postfix (or
        > milter-plugin) *and* strip the NOTIFY section from the SMTP session
        > after the original notify_options are preserved for the mailheader. The

        Converting SMTP command line options into message headers requires
        an SMTP-based filter, for example, smtpd_proxy_filter. See:
        http://www.postfix.org/SMTPD_PROXY_README/html

        The reverse, conversion from from message headers to SMTP command
        line options, also requires an SMTP-based filter.

        Postfix strips SMTP syntax while receiving mail, and adds SMTP
        syntax while delivering mail. The rest of Postfix knows nothing
        about SMTP.

        Wietse
      • Alex
        ... Thank you for your answer. It caused me to take another look at: http://www.postfix.org/SMTPD_PROXY_README.html#config For non-SMTP capable content
        Message 3 of 4 , Jul 22, 2014
        • 0 Attachment
          On 2014-07-22 13:12, wietse@... wrote:
          > Alex:
          >> Hi folks,
          >>
          >> Situation:
          >> Hoping to tie Postfix into a chain of software and hardware appliances
          >> as a Message Bus, most of which is outside of my control. Postfix is
          >> run
          >> inside a heavily firewalled network, no e-mail incoming from the
          >> outside
          >> world.
          >>
          >> I'm trying to find out how (much work it is) to transform/convert the
          >> RCPT TO line--*including* the NOTIFY section--from the incoming SMTP
          >> session with an e-mail, into a mailheader with Postfix (or
          >> milter-plugin) *and* strip the NOTIFY section from the SMTP session
          >> after the original notify_options are preserved for the mailheader.
          >> The
          >
          > Converting SMTP command line options into message headers requires
          > an SMTP-based filter, for example, smtpd_proxy_filter. See:
          > http://www.postfix.org/SMTPD_PROXY_README/html

          > Postfix strips SMTP syntax while receiving mail, and adds SMTP
          > syntax while delivering mail. The rest of Postfix knows nothing
          > about SMTP.
          >
          > Wietse

          Thank you for your answer. It caused me to take another look at:
          http://www.postfix.org/SMTPD_PROXY_README.html#config
          "For non-SMTP capable content filtering software, Bennett Todd's SMTP
          proxy implements a nice PERL/SMTP content filtering framework. See:
          http://bent.latency.net/smtpprox/."

          bent.latency.net is (and was also yesterday) unreachable, I guess that's
          why I skimmed over the nearby text. But archive.org was useful:
          https://web.archive.org/web/20131210174626/http://bent.latency.net/

          And https://github.com/jnorell/smtpprox

          FYI: the Perl community prefers the name written as "Perl" or "perl"
          over "PERL":
          http://learn.perl.org/faq/perlfaq1.html#Whats-the-difference-between-perl-and-Perl-

          Kind regards,

          Alex
        • Wietse Venema
          ... Thanks. I ll add the pointer to the github repository. The postfix.org website will show the change after the next Postfix development release. BTW That
          Message 4 of 4 , Jul 22, 2014
          • 0 Attachment
            Alex:
            > Thank you for your answer. It caused me to take another look at:
            > http://www.postfix.org/SMTPD_PROXY_README.html#config
            > "For non-SMTP capable content filtering software, Bennett Todd's SMTP
            > proxy implements a nice PERL/SMTP content filtering framework. See:
            > http://bent.latency.net/smtpprox/."
            >
            > bent.latency.net is (and was also yesterday) unreachable, I guess that's
            > why I skimmed over the nearby text. But archive.org was useful:
            > https://web.archive.org/web/20131210174626/http://bent.latency.net/
            >
            > And https://github.com/jnorell/smtpprox

            Thanks. I'll add the pointer to the github repository. The postfix.org
            website will show the change after the next Postfix development release.

            BTW That text was written over 10 years ago, so it's pretty impressive
            that it has held up for such a long time.

            Wietse
          Your message has been successfully submitted and would be delivered to recipients shortly.