0

How can I block outgoing mail for a specific user ([email protected]) in Postfix to all but a specific list of domains (e.g. @example.com, @dot1q.com)?

I found a solution to block mail to a specific domain:

Edit the main.cf file (the default location is in /etc/postfix) and add transport_maps = hash:/etc/postfix/transport to the file. Create a file named /etc/postfix/transport, if it doesn’t exist. Add the following at the end of the transport file: example.com : dot1q.com : * discard:

but this unfortunately blocks email for all users. Is it possible to make this work for only one user [email protected]?

1

2 Answers 2

0

The correct syntax for the transport file in you case should be (using regular expressions):

/^user@example\.com/ discard: /.*/ : 

The first line tells postfix to discard mail sent with address [email protected], the second line tess postfix to accept everything else.

0

Postfix provides 'check_sender_access' parameter. It can be used in /etc/postfix/main.cf as

smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/access 

To block, out going emails for [email protected], create /etc/postfix/access with following

[email protected] REJECT 

after that run below commands

postmap /etc/postfix/access service postfix restart 

If you are using sendmail as a MTA then you edit the file /etc/mail/access and add the following rule in it,

From:[email protected] REJECT 

then restart the sendmail service as,

service sendmail restart 

the user 'test' should not be able to send mails.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.