Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to block mail sending to yahoo or gmail from my mail server but I want to continue receiving mails from yahoo/gmail. I am using ubuntu 10.04 LTS, postifx mail server with mysql virtual mailboxes.

share|improve this question
up vote 0 down vote accepted

You need to work with transport_maps. So put in

transport_maps = hash:/etc/postfix/transport

Then in /etc/postfix/transport put     error:You are not allowed to contact Google     error:You are not allowed to contact Google     error:You are not allowed to contact Yahoo

Don't forget to postmap /etc/postfix/transport afterwards.

Note that this will only deny the mentioned domain names. Not the MX records at all. Yahoo and Google have plenty alternative domain names that you have to take care of. So it would be probably better to firewall their MX servers. Which on the other hand will deny all mails to domains hosted at Google Apps or Google for Business.

share|improve this answer
Thanks!!! It's work for me!! – user103373 Jan 3 '12 at 6:48

Try postfix restriction classes, i believe it's what you need. Reference:

share|improve this answer
This will only work for incoming mail. – mailq Dec 30 '11 at 23:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.