Hi Noel, I just tested Your solution, but its not working with multiple RCPT TO:
When I`m sending an E-mail using telnet command, an email with single RCPT TO: zalezny.niezale...@gmail.com is working fine. its blocked. But when I will put second RCPT TO: u...@domain.com, then both E-mails are send, even that restricted by transport table. @Wietse , maybe You will be able to help me here ? With kind regards Zalezny On Mon, Jun 27, 2016 at 5:29 PM, Zalezny <zalezny.niezale...@gmail.com> wrote: > Wow, thanks for that perfect tip. > > > > > On June 27, 2016 5:15:52 PM GMT+02:00, Noel Jones <njo...@megan.vbhcs.org> > wrote: >> >> On 6/27/2016 3:39 AM, Zalezny Niezalezny wrote: >> >>> Hi, >>> >>> using header_checks configuration we are dropping all outgoing >>> E-mails except some of them. >>> >>> >>> # discard all mails not going to cortalconsors.(de|fr) >>> if /^to:/ >>> !/^to:<?.*@(extern\.)?(domain)\.(com)>?$/ DISCARD discarded >>> endif >>> >>> Following rules dropping all outgoing e-mails with recipeint domains >>> different than >>> >>> extern.domain.com <http://extern.domain.com> >>> domain.com <http://domain.com> >>> >>> When You sending an E-mail to: >>> >>> To:<zalezny.niezale...@gmail.com <mailto:zalezny.niezale...@gmail.com>> >>> >>> >>> Postfix dropping that E-mail. >>> >>> >>> >>> But when You will send an e-mail to two recipients >>> >>> To:<u...@extern.domain.com >>> <mailto:u...@extern.domain.com>>,<zalezny.niezale...@gmail.com >>> <mailto:zalezny.niezale...@gmail.com>> >>> >>> system will deliver both. >>> >>> >>> >>> >>> Why system not dropping E-mail addressed to >>> <zalezny.niezale...@gmail.com <mailto:zalezny.niezale...@gmail.com>> >>> ? Its clear described in the rule, drop all except... >>> >>> >>> I will appreciate for any help. >>> >>> >>> >>> >>> With kind regards >>> >>> zalezny >>> >>> >>> >> >> The failure you're seeing when there are two addresses in the header >> is because your expression only matches when there is a single >> address. But header_checks is the wrong tool for this job; the To: >> header does not control where mail is delivered. >> >> A >> more robust solution is to limit where postfix can deliver mail. >> >> # main.cf >> default_transport = error:remote delivery disabled >> transport_maps = hash:/etc/postfix/transport >> >> # /etc/postfix/transport >> domain.com smtp: >> extern.domain.com smtp: >> >> >> >> http://www.postfix.org/transport.5.html >> >> >> >> -- Noel Jones >> >> > -- > Sent from my Android device with K-9 Mail. Please excuse my brevity. >