Skip to main content

Easiest way to block all outgoing mail to a domain

Comments

7 comments

  • cPanelMichael
    Hello :) This post is a little older, but it's similar to what you are seeking: Block Email to AOL However, note that the /etc/cpanel_exim_system_filter should be used instead of the file mentioned in that post. Thank you.
    0
  • webmasteryoda
    Nope. It doesnt work. File exists and I can easily change it, but after any kind of change server stops sending mails completely. Later, if I delete the lines or comment them, mail server works again. I even tried to copy-paste these lines just to be sure I am typing correctly, but it doesnt work: if $header_from: contains "@thedomain_you_want_to_block_to_aol" then if $header_to: contains "@aol.com" then fail text "The message you want to send to the originator of this email" seen finish end end if not first_delivery then finish endif
    Is it matters where in the file I type my lines? At the bottom or somewhere in the middle? :confused:
    0
  • cPanelMichael
    It's possible those rules are no longer sufficient. Have you considered attempting to block the Yahoo mail IP addresses through your firewall instead? I found the following example in the search results on Google: iptables -I OUTPUT -s 127.0.0.1 -m string --string "domain" -j DROP
    Thank you.
    0
  • webmasteryoda
    Thanks Michael. I know that iptables is Linux firewall. But my knowledge with command line is very poor. So, you are suggesting me to type: iptables -I OUTPUT -s 127.0.0.1 -m string --string "yahoo.com" -j DROP
    via SSH? If I do that now, how can I remove this block in iptables when I solve the problem? Thanks in advance and please sorry for my limited knowledge.
    0
  • cPanelMichael
    Yes, you could try that command. However, it was simply provided as an example found in search results. It's not guaranteed to work, and you should use it as your own risk. To delete a rule, you could first search for the rule via: iptables -L --numeric --line-numbers |grep yahoo.com
    To delete it, simply run this command: iptables -D INPUT 123
    Replace "123" with the line number from the first result. Thank you.
    0
  • webmasteryoda
    Suggested command returns this: iptables v1.4.7: STRING match: You must specify `--algo'
    I dont get it. Maybee its easier to ask email users not to send emails to Yahoo... :) Ofc... its just a joke... :)
    0
  • webmasteryoda
    Ok. Problem solved. I dont know why, but previous method didnt work. Probably some changes in the cpanel exim filter syntax. This is now correct and works nice. if $header_to: contains "@yahoo.com" then fail text "Your message to inform email users about the problem..." seen finish endif if not first_delivery then finish endif
    And now my email server blocks all outgoing mails to Yahoo. I hope that they will automaticaly remove me from the blacklist. Cheers to all. And specially to cPanel crew.
    0

Please sign in to leave a comment.