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

Quarantine mail by combination of address class and MIME type

Expand Messages
  • Philip Garrett
    I have a special-purpose Postfix 2.6 server that is part of a content conversion system. I would like to quarantine any outbound mail that hasn t been
    Message 1 of 5 , Oct 3, 2013
    • 0 Attachment
      I have a special-purpose Postfix 2.6 server that is part of a content conversion system. I would like to quarantine any outbound mail that hasn't been transformed properly. I'd also like to quarantine relay mail that hasn't gone through the reciprocal transformation.

      I can hold the mail using mime_header_checks, but this would apply to both outbound (default domain class) and inbound (relay domain class). What I really want to do is something like this:

      if DEFAULT_DOMAIN_CLASS
      if /^Content-Type:/
      !/^Content-Type:\s*application\/x-my-custom-format/
      HOLD was not encoded
      endif
      endif

      if RELAY_DOMAIN_CLASS
      if /^Content-Type:/
      /^Content-Type:\s*application\/x-my-custom-format/
      HOLD was not decoded
      endif
      endif

      Is there a way to accomplish that?

      Thanks,
      Philip
    • Noel Jones
      ... header (and body) checks evaluate a single header (or line) at a time with no state saved in between, so you can t combine multiple conditions. One
      Message 2 of 5 , Oct 3, 2013
      • 0 Attachment
        On 10/3/2013 12:49 PM, Philip Garrett wrote:
        > I have a special-purpose Postfix 2.6 server that is part of a content conversion system. I would like to quarantine any outbound mail that hasn't been transformed properly. I'd also like to quarantine relay mail that hasn't gone through the reciprocal transformation.
        >
        > I can hold the mail using mime_header_checks, but this would apply to both outbound (default domain class) and inbound (relay domain class). What I really want to do is something like this:
        >
        > if DEFAULT_DOMAIN_CLASS
        > if /^Content-Type:/
        > !/^Content-Type:\s*application\/x-my-custom-format/
        > HOLD was not encoded
        > endif
        > endif
        >
        > if RELAY_DOMAIN_CLASS
        > if /^Content-Type:/
        > /^Content-Type:\s*application\/x-my-custom-format/
        > HOLD was not decoded
        > endif
        > endif
        >
        > Is there a way to accomplish that?
        >
        > Thanks,
        > Philip
        >


        header (and body) checks evaluate a single header (or line) at a
        time with no state saved in between, so you can't combine multiple
        conditions.

        One possible solution is using separate postfix instances for
        incoming and outgoing mail, effectively splitting the mail flow into
        domain classes before the mime_header_checks see the message.
        http://www.postfix.org/MULTI_INSTANCE_README.html

        Alternately, a custom perl or python milter should be able to do this.
        http://www.postfix.org/MILTER_README.html



        -- Noel Jones
      • Viktor Dukhovni
        ... Your best bet is a multi-instance configation, with separate inbound and outbound mail processing. Mail coming from inside is accepted by the input stage
        Message 3 of 5 , Oct 3, 2013
        • 0 Attachment
          On Thu, Oct 03, 2013 at 01:49:11PM -0400, Philip Garrett wrote:

          > I have a special-purpose Postfix 2.6 server that is part of a
          > content conversion system. I would like to quarantine any outbound
          > mail that hasn't been transformed properly. I'd also like to
          > quarantine relay mail that hasn't gone through the reciprocal
          > transformation.
          >
          > I can hold the mail using mime_header_checks, but this would apply to both outbound (default domain class) and inbound (relay domain class). What I really want to do is something like this:
          >
          > if DEFAULT_DOMAIN_CLASS
          > if /^Content-Type:/
          > !/^Content-Type:\s*application\/x-my-custom-format/
          > HOLD was not encoded
          > endif
          > endif
          >
          > if RELAY_DOMAIN_CLASS
          > if /^Content-Type:/
          > /^Content-Type:\s*application\/x-my-custom-format/
          > HOLD was not decoded
          > endif
          > endif
          >
          > Is there a way to accomplish that?

          Your best bet is a multi-instance configation, with separate inbound
          and outbound mail processing.

          Mail coming from inside is accepted by the input stage of the
          outbound MTA, and if some of the recipients are internal those are
          routed to the input stage of the inbound MTA.

          Mail coming from outside is accepted by the input stage of the
          inbound MTA, and if some of the recipients are external those are
          routed to the input stage of the inbound MTA.

          Between the input and output stage of each direction is a transparent
          proxy performing the desired transformation which is the
          default_transport for the corresponding input stage.

          http://www.postfix.org/MULTI_INSTANCE_README.html

          You have a recipient-specific policy, but Postfix content filtering
          happens at the message level on input, hence you need to "split the
          envelope" before filtering, by routing recipients with different
          policies via distinct flows.

          --
          Viktor.
        • Philip Garrett
          ... I was afraid of that. ... This is true, but I would be happy to apply the policy at the entire message level. That is, it s ok to quarantine if it has
          Message 4 of 5 , Oct 3, 2013
          • 0 Attachment
            On Oct 3, 2013, at 2:09 PM, Viktor Dukhovni <postfix-users@...> wrote:

            > Your best bet is a multi-instance configation, with separate inbound
            > and outbound mail processing.

            I was afraid of that.

            > You have a recipient-specific policy, but Postfix content filtering
            > happens at the message level on input, hence you need to "split the
            > envelope" before filtering, by routing recipients with different
            > policies via distinct flows.

            This is true, but I would be happy to apply the policy at the entire message level. That is, it's ok to quarantine if it has *any* relay-class recipients with the wrong type OR any default-class recipients with the wrong type. I would rather quarantine the message for all recipients, even if only some are bad.

            Does that change your answer at all?

            Thanks,
            Philip
          • Viktor Dukhovni
            ... No. And multiple instances are not scary. They are easier to support, since each instance is simpler, and you can monitor separate pre and post filter
            Message 5 of 5 , Oct 3, 2013
            • 0 Attachment
              On Thu, Oct 03, 2013 at 02:45:41PM -0400, Philip Garrett wrote:

              > On Oct 3, 2013, at 2:09 PM, Viktor Dukhovni <postfix-users@...> wrote:
              >
              > > Your best bet is a multi-instance configation, with separate inbound
              > > and outbound mail processing.
              >
              > I was afraid of that.
              >
              > > You have a recipient-specific policy, but Postfix content filtering
              > > happens at the message level on input, hence you need to "split the
              > > envelope" before filtering, by routing recipients with different
              > > policies via distinct flows.
              >
              > This is true, but I would be happy to apply the policy at the entire message level. That is, it's ok to quarantine if it has *any* relay-class recipients with the wrong type OR any default-class recipients with the wrong type. I would rather quarantine the message for all recipients, even if only some are bad.
              >
              > Does that change your answer at all?

              No. And multiple instances are not scary. They are easier to
              support, since each instance is simpler, and you can monitor separate
              pre and post filter queues, ... Make the jump, it is worth it.

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