Block Emails on Postfix
Can anyone explain how I can place a filter or block list of email accounts I do not wish to be able to communicate with my email server? For example, I do not want anyone to be able to send and or receive email from *@aol.com using my MTA. Is there a way in Postfix I can block all SMTP traffic (in/out) to any or all AOL email accounts?
|
You should be able to do this with the smtpd_recipient_restrictions in the main.cf configuration.
Might end up looking something like this in your conf: Code:
smtpd_recipient_restrictions = permit_mynetworks, check_sender_access regexp:/etc/postfix/unwanted_sender, reject_unauth_destination Upon further readings though, this might only reject outgoing email. For incoming, I'd just use SpamAssassin to block unwanted emails. |
So w/o SA, there is no way to filter emails from any specific domain? I am testing this now now on my server to see if I can receive from Gmail and just not send and or both...
Right now I have the following in main.cf Code:
smtpd_recipient_restrictions = |
For inbound email, add a check_sender_access to your smtpd_recipient_restrictions to create a blacklists for senders from domains or addresses you wish to block:
Code:
main.cf: For outbound email, you can create an AOL-specific transport that sends to error: Code:
main.cf: |
Mr. C - I have done the following:
Code:
smtpd_recipient_restrictions = Thanks for any assistance! |
Since you have the file listed as a hash file:
Code:
check_sender_access hash:/etc/postfix/sender_checks Postmap translates ASCII text files into a database format. This is required for hash, db, and dbm files, and any other file which is a "database" format. If you specify the files as regexp or pcre, you don't need to postmap, because the files are not database files, but are read directly. If you are unsure of a table type, do a man on the table type, as in: Code:
man cidr_table |
OK - Thanks for clearing that up for me. I was not sure when to use Postmap and when it is not needed...
So if I have a file called foo and foo.db and in my main.cf it is being called as regexp or pcre - then I don't need foo.db, correct? Is there a benefit to using one of the mentioned above? Seems like regexp would be preferred so you don't have to postmap anything when you make a change, right? |
Right, with pcre/regexp, you just use the text file - no .db file required or used.
The choice of file types you use depends on what you are trying to do, and concerns about performance. Pcre is faster than regexp, so use pcre if you have pcre built in. Use hash's for longer lists, since db lookups are faster than long pcre or regexp lists. If you only have a few entires, the table choice doesn't matter much. Pick one that suits your needs. |
Quote:
Code:
transport_maps = hash:/etc/postfix/transport |
No, it does not matter where in the file you place the settings.
|
All times are GMT -5. The time now is 04:00 PM. |