How to REJECT/DISCARD mails from a domain BUT NOT subdomin in POSTFIX
(PREFACE: This forum doesn't allow me yet to post AT symbol, cause it thinks I'm posting an email link. So consider I changed al AT symbol as İ to write this post)
I have a CentOS 5.5 w/ Postfix 2.3.3-2.1 in a machine that acts as a Mail Gateway, in the DMZ side of my network.
Lets say for example that my MX domain is "mydomain.com"
In order to avoid SPAM mails that usually come with the domain part of the sender like mydomain from external (es. From: fooİmydomain.com To: user.nameİdomain.com), I put a line in access_sender file like the following:
Obviously I have a line in my main.cf that reads:
mydomain.com DISCARD No mails from external with mydomain name.
This worked, but unfortunately it discarded even mails that had From like "someoneİcertmail.mydomain.com".
Since I wanted them to enter in my network, I changed the access_sender file to read:
So, I put the AT "İ" before the domain. It seemed to work for a first while, but now (maybe after a postfix upgrade) it doesn't any longer.
İmydomain.com DISCARD No mails from external with mydomain name.
It makes all the mails pass to the internal network (until reaching the mail server in transport), just like the line rule were not present at all...
If I try to regexp the rule in regexp/pcre:headers_checks file like the following:
I get a DEVASTATING result because it blocks all the mails coming from external, but all the mails the mails my users try to send out as well !!
/From:.*İmydomain.com/ DISCARD No mails from external with mydomain
So, in other hands, I'd like to write down a rule for my mail gateway with postfix that:
- DISCARDs mails from external with From = *İmydomain.com
- ACCEPTs mails from external with From = *İ<anysubdom>.mydomain.com
- ACCEPTs mails sent from "mynetworks" to external
Tnx in advance