Link to home
Start Free TrialLog in
Avatar of Vijay Kumar Gajula
Vijay Kumar Gajula

asked on

Reject incoming email for specific user - postfix

Can any one let me know how to block incoming emails for specif user / id in Postfix. Other's should get mails normally.

Please let me know the procedure.
Avatar of Tahir Qureshi
Tahir Qureshi
Flag of Australia image

By default, the Postfix SMTP server accepts any sender address. However you can block / blacklist sender email address easily with Postfix. It has SMTP server access table.

Open /etc/postfix/sender_access file
# cd /etc/postfix
# vi sender_access

Append sender email id as follows: REJECT

Save and close the file. Use postmap command to create a database:
# postmap hash:sender_access

Now open and add code as follows:
smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/sender_access

Save and close the file. Restart / reload postfix MTA:
# /etc/init.d/postfix restart

You can also use spamassassin to blacklist email address. Just add to your own spamassassin configuration or to /etc/mail/spamassassin/ file:
# vi /etc/mail/spamassassin/

Append blacklist as follows:

Save and close the file. Restart spamassassin:
# /etc/init.d/spamassassin restart

spamassassin will marke mail as SPAM instead of rejecting the same.
Avatar of Vijay Kumar Gajula
Vijay Kumar Gajula


Thanks for quick response, My requirement is different I need to block mails to particular mail id in my mail server. for example.. my domain name is I have created user as, . Now 1@abc should not receive any mail from out side (external mails).
In this case, how to move forward.

Avatar of arnold
You would need to use a filter prior to delivery checking if the sender is external to the local domain, then either reject or drop the message.
What is the reason for the close selecting a comment that NLA doscribes what you want?
I provided you various suggestions to achieve it depending on what your setup is.
Hi Arnold, Please let me know what went wrong with me?
I do not know, you commented what you want and the selected that comment as the answer.

To limit an email to receiving only internal emails, meaning from local/known domains means that you have to make that determination either during the local delivery using a filter that checks the sending domain against a list of allowed or implement some milter on the incoming (SMTP session processing) which has a backend db, or someway to reference incoming recipient and their rules/rights.


How many such users/email addresses do you have? What does your mail setup consist of, post of, backend MySQL, etc?
we are using Postfix Mail server with about 100 users.
Avatar of arnold
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial