How can I create a user account filter with postfix?
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
You can do something similar to this. You would put your son's email address in the protected_destinations file of the example, and the whitelisted addresses in insiders. Mail to your son's address would be rejected unless the sender is in the whitelist.
You'd have to do something like this, which is incorrect, so read the entire post:
Code:
#/etc/postfix/insiders
#
dad@home.net OK
mom@home.net OK
unclebill@work.org OK
# redirect to dad if sent from anyone else
* REDIRECT dad@home.net
This is incorrect because you cannot have a catch-all in a hash table (someone
correct me if I'm wrong). But, you can do it using a pcre table, for example.
Code:
#/etc/postfix/insiders
#
# this is a pcre table. change the main.cf setting in the example to
# insiders_only = check_sender_access pcre:/etc/postfix/insiders, reject
/^dad@home.net$/ OK
/^mom@home.net$/ OK
/^unclebill@work.org$/ OK
/./ REDIRECT dad@home.net
On the cusp of perfection here. It rejects emails instead of redirecting them. Not sure why. here is the file:
Code:
#/etc/postfix/insiders
#
# this is a pcre table. change the main.cf setting in the example to
# insiders_only = check_sender_access pcre:/etc/postfix/insiders, reject
/^user@domain.com$/ OK
/./ REDIRECT user@domain2.com
Here is a bit of the log.
Code:
Jun 23 18:38:20 mail postfix/postfix-script[23222]: refreshing the Postfix mail system
Jun 23 18:38:20 mail postfix/master[14085]: reload -- version 2.7.0, configuration /etc/postfix
Jun 23 18:38:55 mail postfix/smtpd[23655]: connect from XXXXXXXXXXXXXXXXXXXX.net[76.XX.XX.XX]
Jun 23 18:38:55 mail postfix/smtpd[23655]: NOQUEUE: redirect: RCPT from XXXXXXXXXXXXXXXXXXXX.net[76.XX.XX.XX8]: <XXXX@domain1.net>: Sender address triggers REDIRECT user@domainredirect.com; from=<XXXX@domain1.net> to=<user@intendeduser.com> proto=ESMTP helo=<XXXXXXXXXXXXXX.net>
Jun 23 18:38:55 mail postfix/smtpd[23655]: NOQUEUE: reject: RCPT from XXXXXXXXXXXXXXXXXXXXXXXXXXX.net[76.XX.XX.XX]: 554 5.7.1 <user@intendeduser.com>: Recipient address rejected: Access denied; from=<XXXX@domain1.net> to=<user@intendeduser.com> proto=ESMTP helo=<XXXXXXXXXXXXXXXXXXXXXXXXXXXX.net>
Last edited by 3rods; 06-23-2010 at 05:44 PM.
Reason: add log
Messages get delivered to the redirect and not rejected. I'm guessing this is because we are actually never rejecting any messages and creating a catch all.
It also looks like you can explicitly imply a REJECT action within the file and still have the message trickle down to the catch all if it does not match the rule - which is good.
that's correct. excellent work, 3rods.
but, not for the reason you gave. we are creating a catchall for the sender,
not for the recipients, and only when message are sent to a certain address.
for example, if you sent a message to nonexistent@home.net (assuming home.net
is local to the mail server), then mail would be rejected.
the reason is mentioned in the discussion here.
it means that a REDIRECT action does not stop the key lookup in the access list, which in our case, continues with the
reject rule.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.