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

Maildrop filtering

Expand Messages
  • Ben
    Hi all, I would like to set up mail filtering on a postfix server. I have read a lot of documentation, but I can t make it works. Here s what I did : - install
    Message 1 of 9 , Dec 1, 2010
    • 0 Attachment
      Hi all,

      I would like to set up mail filtering on a postfix server. I have read a
      lot of documentation, but I can't make it works.

      Here's what I did :

      - install maildrop package (should I use maildrop or courier-maildrop ?)
      - create /etc/maildroprc
      - set maildrop transport in master.cf :
      maildrop unix - n n - - pipe
      flags=ODRhu user=www-data argv=/usr/bin/maildrop -d
      ${user}@${nexthop} ${extension} ${recipient} ${user} ${nexthop} ${sender}
      - setuid / setgid on maildrop binary, chown
      - add conf to main.cf :
      virtual_transport = maildrop
      maildrop_destination_recipient_limit = 1

      The problem is that maildrop seems to never been invoked. Postfix choose
      local to deliver the mail, but I can't find why. I would like it uses
      maildrop instead.
      I join postconf -n, maildroprc, and a log extract showing the problem.

      Any idea ?

      Regards,

      Ben
    • Christoph Anton Mitterer
      ... You need to set up your hosted domains to be virtual hosted (http://www.postfix.org/VIRTUAL_README.html). Or change the transport for local delivery...
      Message 2 of 9 , Dec 1, 2010
      • 0 Attachment
        On Wed, 2010-12-01 at 17:41 +0100, Ben wrote:
        > Postfix choose
        > local to deliver the mail, but I can't find why. I would like it uses
        > maildrop instead.
        You need to set up your hosted domains to be virtual hosted
        (http://www.postfix.org/VIRTUAL_README.html).

        Or change the transport for local delivery...


        Cheers,
        Chris.
      • Ralf Hildebrandt
        ... Do you really want to use maildrop for filtering? It s only feasible if your users can edit the filter file. If it s just for you then it s probably ok. --
        Message 3 of 9 , Dec 1, 2010
        • 0 Attachment
          * Ben <ben.div@...>:
          > Hi all,
          >
          > I would like to set up mail filtering on a postfix server. I have
          > read a lot of documentation, but I can't make it works.

          Do you really want to use maildrop for filtering? It's only feasible
          if your users can edit the filter file. If it's just for you then it's
          probably ok.

          --
          Ralf Hildebrandt
          Geschäftsbereich IT | Abteilung Netzwerk
          Charité - Universitätsmedizin Berlin
          Campus Benjamin Franklin
          Hindenburgdamm 30 | D-12203 Berlin
          Tel. +49 30 450 570 155 | Fax: +49 30 450 570 962
          ralf.hildebrandt@... | http://www.charite.de
        • mouss
          ... if postfix chooses local , then it probably means the recipient domain is in mydestination (in contrast to virtual_mailbox_domains, virtual_alias_domains,
          Message 4 of 9 , Dec 1, 2010
          • 0 Attachment
            Le 01/12/2010 17:41, Ben a écrit :
            > Hi all,
            >
            > I would like to set up mail filtering on a postfix server. I have read a
            > lot of documentation, but I can't make it works.
            >
            > Here's what I did :
            >
            > - install maildrop package (should I use maildrop or courier-maildrop ?)
            > - create /etc/maildroprc
            > - set maildrop transport in master.cf :
            > maildrop unix - n n - - pipe
            > flags=ODRhu user=www-data argv=/usr/bin/maildrop -d ${user}@${nexthop}
            > ${extension} ${recipient} ${user} ${nexthop} ${sender}
            > - setuid / setgid on maildrop binary, chown
            > - add conf to main.cf :
            > virtual_transport = maildrop
            > maildrop_destination_recipient_limit = 1
            >
            > The problem is that maildrop seems to never been invoked. Postfix choose
            > local to deliver the mail, but I can't find why.

            if postfix chooses "local", then it probably means the recipient domain
            is in mydestination (in contrast to virtual_mailbox_domains,
            virtual_alias_domains, ...).

            You seem to talk about mail sent to=<test_domain.com@...>

            and you have

            myhostname = mx1.hoster.com

            with no mydestination setting, so you probably have:
            # postconf mydestination
            mydestination = $myhostname, localhost.$mydomain, localhost

            which contains myhostname, thus mx1.hoster.com is a "local" domain in
            your configuration, and virtual_transport has no influence on mail sent
            to this domain.

            PS. next time, avoid hijacking domains such as "hoster.com". use
            example.com, example.net, example.org or any *.example instead.






            > I would like it uses
            > maildrop instead.
            > I join postconf -n, maildroprc, and a log extract showing the problem.
            >
            > Any idea ?
            >
            > Regards,
            >
            > Ben
            >
            >
          • Ben
            ... Thank you for your reply. I have a lot of difficulties to set up what I want with Postfix... The box have a mass hosting software that came with its own
            Message 5 of 9 , Dec 3, 2010
            • 0 Attachment
              Le 01/12/2010 17:52, Christoph Anton Mitterer a écrit :
              > On Wed, 2010-12-01 at 17:41 +0100, Ben wrote:
              >> Postfix choose
              >> local to deliver the mail, but I can't find why. I would like it uses
              >> maildrop instead.
              > You need to set up your hosted domains to be virtual hosted
              > (http://www.postfix.org/VIRTUAL_README.html).
              >
              > Or change the transport for local delivery...
              >

              Thank you for your reply.
              I have a lot of difficulties to set up what I want with Postfix...

              The box have a mass hosting software that came with its own postfix
              configuration. I just want to modify it slightly to use maildrop to sent
              spam in an IMAP spam folder instead of inbox.

              By default, local is used for delivering. Setting
              virtual_mailbox_domains correctly allowed me to use maildrop transport
              for delivering. But it breaks email relaying (ex : test@... must be
              delivered locally, and forwarded to test@...). The local
              delivery works (with maildrop), but the mail is not forwarded (User
              unknown in virtual mailbox table (state 14)).

              So, I've tried to use maildrop for local_transport, but if I don't set
              virtual_mailbox_domains, email have such a form :
              user_domain.com@.... So maildrop said user unknown. Command
              output: Invalid user specified. It work only with user@...

              It's hell so, as I don't know how the mass hosting software set Postfix,
              and don't know well the postfix configuration...

              Any help greatly appreciated !

              Regards,

              Ben
            • mouss
              ... you want: - accept mail. it seems this already works for you - pass mail to maildrop. apparently, you did so for virtual domains. from your previous posts,
              Message 6 of 9 , Dec 3, 2010
              • 0 Attachment
                Le 03/12/2010 17:28, Ben a écrit :
                > Le 01/12/2010 17:52, Christoph Anton Mitterer a écrit :
                >> On Wed, 2010-12-01 at 17:41 +0100, Ben wrote:
                >>> Postfix choose
                >>> local to deliver the mail, but I can't find why. I would like it uses
                >>> maildrop instead.
                >> You need to set up your hosted domains to be virtual hosted
                >> (http://www.postfix.org/VIRTUAL_README.html).
                >>
                >> Or change the transport for local delivery...
                >>
                >
                > Thank you for your reply.
                > I have a lot of difficulties to set up what I want with Postfix...
                >
                > The box have a mass hosting software that came with its own postfix
                > configuration. I just want to modify it slightly to use maildrop to sent
                > spam in an IMAP spam folder instead of inbox.
                >
                > By default, local is used for delivering. Setting
                > virtual_mailbox_domains correctly allowed me to use maildrop transport
                > for delivering. But it breaks email relaying (ex : test@... must be
                > delivered locally, and forwarded to test@...). The local
                > delivery works (with maildrop), but the mail is not forwarded (User
                > unknown in virtual mailbox table (state 14)).
                >
                > So, I've tried to use maildrop for local_transport, but if I don't set
                > virtual_mailbox_domains, email have such a form :
                > user_domain.com@.... So maildrop said user unknown. Command
                > output: Invalid user specified. It work only with user@...
                >
                > It's hell so, as I don't know how the mass hosting software set Postfix,
                > and don't know well the postfix configuration...
                >
                > Any help greatly appreciated !
                >


                you want:

                - accept mail. it seems this already works for you

                - pass mail to maildrop. apparently, you did so for virtual domains.
                from your previous posts, you seem to have a problem with local mail. if
                still, you'll need to configure postfix to pass such mail to maildrop.
                there are many ways..

                - configure maildrop to accept user/recipient and to deliver where it
                should. This is not a postfix issue. you'll get more help on the
                maildrop-users mailing list.



                - you can use maildrop for local and/or for virtual mailbox domains. you
                can even use maildrop via transport_maps, in which case the domain
                "class" doesn't matter.


                - if you use maildrop with virtual domains, you'll need to tell maildrop
                how to find the user and his config (mailbox location, ...). This is a
                maildrop configuration question.
              • Ben
                ... All domains are virtual, I managed to pass all mails to maildrop, it works. The problem is that in this configuration, mail are not relayed to other hosts
                Message 7 of 9 , Dec 3, 2010
                • 0 Attachment
                  Le 03/12/2010 17:39, mouss a écrit :
                  > Le 03/12/2010 17:28, Ben a écrit :
                  >> Le 01/12/2010 17:52, Christoph Anton Mitterer a écrit :
                  >>> On Wed, 2010-12-01 at 17:41 +0100, Ben wrote:
                  >>>> Postfix choose
                  >>>> local to deliver the mail, but I can't find why. I would like it uses
                  >>>> maildrop instead.
                  >>> You need to set up your hosted domains to be virtual hosted
                  >>> (http://www.postfix.org/VIRTUAL_README.html).
                  >>>
                  >>> Or change the transport for local delivery...
                  >>>
                  >>
                  >> Thank you for your reply.
                  >> I have a lot of difficulties to set up what I want with Postfix...
                  >>
                  >> The box have a mass hosting software that came with its own postfix
                  >> configuration. I just want to modify it slightly to use maildrop to sent
                  >> spam in an IMAP spam folder instead of inbox.
                  >>
                  >> By default, local is used for delivering. Setting
                  >> virtual_mailbox_domains correctly allowed me to use maildrop transport
                  >> for delivering. But it breaks email relaying (ex : test@... must be
                  >> delivered locally, and forwarded to test@...). The local
                  >> delivery works (with maildrop), but the mail is not forwarded (User
                  >> unknown in virtual mailbox table (state 14)).
                  >>
                  >> So, I've tried to use maildrop for local_transport, but if I don't set
                  >> virtual_mailbox_domains, email have such a form :
                  >> user_domain.com@.... So maildrop said user unknown. Command
                  >> output: Invalid user specified. It work only with user@...
                  >>
                  >> It's hell so, as I don't know how the mass hosting software set Postfix,
                  >> and don't know well the postfix configuration...
                  >>
                  >> Any help greatly appreciated !
                  >>
                  >
                  >
                  > you want:
                  >
                  > - accept mail. it seems this already works for you
                  >
                  > - pass mail to maildrop. apparently, you did so for virtual domains.
                  > from your previous posts, you seem to have a problem with local mail. if
                  > still, you'll need to configure postfix to pass such mail to maildrop.
                  > there are many ways..
                  >
                  All domains are virtual, I managed to pass all mails to maildrop, it
                  works. The problem is that in this configuration, mail are not relayed
                  to other hosts when the user configure mail redirection.
                  A user can tell : keep the received mail in my mail account, and send a
                  copy to anyone@...
                  That's this fonctionnality that doesn't works anymore.

                  I noticed that when I configure domains to be virtual (with
                  virtual_mailbox_domains setting), the mails have a
                  test_thehost.com@... shape.
                  When I don't do this setup, mails have a test@... shape.
                  Maybe it's related to the relay problem.

                  > - configure maildrop to accept user/recipient and to deliver where it
                  > should. This is not a postfix issue. you'll get more help on the
                  > maildrop-users mailing list.
                  >
                  > - you can use maildrop for local and/or for virtual mailbox domains. you
                  > can even use maildrop via transport_maps, in which case the domain
                  > "class" doesn't matter.
                  >
                  I would like to always use maildrop for delivering, but mail redirection
                  don't works anymore when I do that.
                  >
                  > - if you use maildrop with virtual domains, you'll need to tell maildrop
                  > how to find the user and his config (mailbox location, ...). This is a
                  > maildrop configuration question.
                  >
                  You're true, I can set local_transport to maildrop, and try to setup
                  maildrop to deal correctly with test_thehost.com@... mail form.
                  But I don't understand why mail redirection doesn't work anymore when I
                  set domains virtual and mail have a form of test@... shape.

                  I join my postconf -n

                  Thank you very much for your help.

                  Ben
                • mouss
                  ... The big question is: how do they do that? if they edit .forward, well, for sure that won t work. if mail is passed to maildrop, users will need maildrop
                  Message 8 of 9 , Dec 4, 2010
                  • 0 Attachment
                    Le 03/12/2010 17:56, Ben a écrit :
                    > [snip]
                    > All domains are virtual, I managed to pass all mails to maildrop, it
                    > works. The problem is that in this configuration, mail are not relayed
                    > to other hosts when the user configure mail redirection.
                    > A user can tell : keep the received mail in my mail account, and send a
                    > copy to anyone@...

                    The big question is: how do they do that?
                    if they edit .forward, well, for sure that won't work.

                    if mail is passed to maildrop, users will need maildrop filtering
                    snippets...

                    or the forwarding must happen before delivery. for example, with
                    virtual_alias_maps:

                    joe@... joe@..., joe@...

                    will clone the message. then you can configure postfix to relay the
                    second address to where it should go. if you want .forward functionality,
                    replace forward.example.net with a domain listed under mydestination.

                    > That's this fonctionnality that doesn't works anymore.
                    >
                    > I noticed that when I configure domains to be virtual (with
                    > virtual_mailbox_domains setting), the mails have a
                    > test_thehost.com@... shape.
                    > When I don't do this setup, mails have a test@... shape.
                    > Maybe it's related to the relay problem.

                    postfix doesn't do that by default. so you either have something
                    configured to do the rewrite or mail is processed by something external
                    to postfix.

                    most probably:

                    - you used a virtual alias to rewrite
                    test@... test_thehost.com

                    - myorigin is set to mx1.mybox.com, thus test_thehost.com becomes
                    test_thehost.com@...

                    if it's that, then fix your virtual alias entry: add the domain part
                    explicitely. see the example I've given above (the one with "joe...").

                    PS. that doesn't match your claimed 'postconf -n' (your postconf -n says
                    "myorigin=mx1.test.com", not mx1.mybox.com). When you hide private
                    infos, do so coherently. Otherwise, you're only making it hard for us to
                    help you...

                    and anyway, do not hijack valid domains such as test.com and mybox.com.
                    Use example.com, example.net, example.org or *.example.


                    >>
                    > I would like to always use maildrop for delivering, but mail redirection
                    > don't works anymore when I do that.

                    you can either redirect before passing mail to maildrop (example above),
                    or redirect in maildrop (maildrop has a CC and TO commands, among other
                    things).

                    >>
                    >> - if you use maildrop with virtual domains, you'll need to tell maildrop
                    >> how to find the user and his config (mailbox location, ...). This is a
                    >> maildrop configuration question.
                    >>
                    > You're true, I can set local_transport to maildrop, and try to setup
                    > maildrop to deal correctly with test_thehost.com@... mail form.
                    > But I don't understand why mail redirection doesn't work anymore when I
                    > set domains virtual and mail have a form of test@... shape.
                    >
                    > I join my postconf -n
                    >
                    > Thank you very much for your help.
                    >
                    > Ben
                  • Ben
                    ... Well, I managed to do what I need by setting maildrop for both virtual and local transport, and playing with pipe(8) parameters to pass to maildrop a mail
                    Message 9 of 9 , Dec 7, 2010
                    • 0 Attachment
                      Le 05/12/2010 02:51, mouss a écrit :
                      > Le 03/12/2010 17:56, Ben a écrit :
                      >> [snip]
                      >> All domains are virtual, I managed to pass all mails to maildrop, it
                      >> works. The problem is that in this configuration, mail are not relayed
                      >> to other hosts when the user configure mail redirection.
                      >> A user can tell : keep the received mail in my mail account, and send a
                      >> copy to anyone@...
                      >
                      > The big question is: how do they do that?
                      > if they edit .forward, well, for sure that won't work.
                      >
                      > if mail is passed to maildrop, users will need maildrop filtering
                      > snippets...
                      >
                      > or the forwarding must happen before delivery. for example, with
                      > virtual_alias_maps:
                      >
                      > joe@... joe@..., joe@...
                      >
                      > will clone the message. then you can configure postfix to relay the
                      > second address to where it should go. if you want .forward functionality,
                      > replace forward.example.net with a domain listed under mydestination.
                      >
                      >> That's this fonctionnality that doesn't works anymore.
                      >>
                      >> I noticed that when I configure domains to be virtual (with
                      >> virtual_mailbox_domains setting), the mails have a
                      >> test_thehost.com@... shape.
                      >> When I don't do this setup, mails have a test@... shape.
                      >> Maybe it's related to the relay problem.
                      >
                      > postfix doesn't do that by default. so you either have something
                      > configured to do the rewrite or mail is processed by something external
                      > to postfix.
                      >
                      > most probably:
                      >
                      > - you used a virtual alias to rewrite
                      > test@... test_thehost.com
                      >
                      > - myorigin is set to mx1.mybox.com, thus test_thehost.com becomes
                      > test_thehost.com@...
                      >
                      > if it's that, then fix your virtual alias entry: add the domain part
                      > explicitely. see the example I've given above (the one with "joe...").
                      >
                      > PS. that doesn't match your claimed 'postconf -n' (your postconf -n says
                      > "myorigin=mx1.test.com", not mx1.mybox.com). When you hide private
                      > infos, do so coherently. Otherwise, you're only making it hard for us to
                      > help you...
                      >
                      > and anyway, do not hijack valid domains such as test.com and mybox.com.
                      > Use example.com, example.net, example.org or *.example.
                      >
                      >
                      >>>
                      >> I would like to always use maildrop for delivering, but mail redirection
                      >> don't works anymore when I do that.
                      >
                      > you can either redirect before passing mail to maildrop (example above),
                      > or redirect in maildrop (maildrop has a CC and TO commands, among other
                      > things).
                      >
                      Well, I managed to do what I need by setting maildrop for both virtual
                      and local transport, and playing with pipe(8) parameters to pass to
                      maildrop a mail that match mail_user table (myvirtual).
                      And it's done :)
                      Thanks a lot for your help.

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