On 4/20/2015 6:39 PM, Simon wrote: > > > On Tue, Apr 21, 2015 at 11:34 AM, Simon <grem...@gmail.com > <mailto:grem...@gmail.com>> wrote: > > > > On Mon, Apr 20, 2015 at 3:51 PM, Noel Jones > <njo...@megan.vbhcs.org <mailto:njo...@megan.vbhcs.org>> wrote: > > On 4/19/2015 7:03 PM, Simon wrote: > > Hi There, > > > > We are using postfix 2.7.1 on debian. Is there a simple way to block > > emails from a domain or From address only to a certain to address? > > So this would match both from and to in the header to then block the > > email. e.g. > > > > From: blockt...@domain.com <mailto:blockt...@domain.com> > <mailto:blockt...@domain.com <mailto:blockt...@domain.com>> > > To: cli...@theirdomain.com <mailto:cli...@theirdomain.com> > <mailto:cli...@theirdomain.com <mailto:cli...@theirdomain.com>> > > > > Only when blockt...@domain.com <mailto:blockt...@domain.com> > <mailto:blockt...@domain.com <mailto:blockt...@domain.com>> > sent an > > email to cli...@theirdomain.com <mailto:cli...@theirdomain.com> > <mailto:cli...@theirdomain.com <mailto:cli...@theirdomain.com>> > > would it get blocked, otherwise all other emails from > > blockt...@domain.com <mailto:blockt...@domain.com> > <mailto:blockt...@domain.com <mailto:blockt...@domain.com>> > would be sent to > > any other to address? > > You can use a restriction class to block mail for a specific > envelope sender/recipient combination. The envelope > addresses are > what are logged by postfix, and may be different than what > is in the > From: and To: headers. > http://www.postfix.org/RESTRICTION_CLASS_README.html > > If you must use the addresses listed in message headers, you > will > need a content filter such as SpamAssassin. > > > Thanks for the reply here - I think that envelope > sender/recipient combination would be fine :) > > I get the basic idea of the the restriction classes, but finding > it difficult to figure out how to combine to get the result we > need. Would you be able give me a head start on this one? It > would be much appreciated! > > > Just to check on this one.. so am i correct that you would set a > restriction class for the inbound domain (say mailfrom.blockme.com > <http://mailfrom.blockme.com>), then you would set a access list for > that "class"? e.g. within that class block if the recipient is > cleanu...@client.com <mailto:cleanu...@client.com>? > > Simon
A very abbreviated example done off the top of my head late at night: Goal: block mail with sender example.info to recipient b...@example.com # main.cf smtpd_restriction_classes = block_bob block_bob = check_recipient_access hash:/etc/postfix/bob_recipient smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_blocks # Other files: # bob_recipient b...@example.com REJECT sender not allowed for this recipient # sender_blocks example.info block_bob Hope this is close enough to right that it helps. -- Noel Jones