The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Easiest way to block all outgoing mail to a domain

Discussion in 'E-mail Discussions' started by webmasteryoda, Sep 10, 2013.

  1. webmasteryoda

    webmasteryoda Active Member

    Joined:
    Apr 3, 2013
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Serbia
    cPanel Access Level:
    Root Administrator
    Hello

    I want to temporarily block all of the outgoing mails to yahoo.com

    The reason is: Yahoo blocked my IP and they will unblock me if I stop sending mails to their server for at least 48 hours. Check this topic.

    But, I cant expect my email users to obey... :) So, it could be much easier if I temporarily block them all for sending emails to Yahoo.

    Any clues how to do it?
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
  3. webmasteryoda

    webmasteryoda Active Member

    Joined:
    Apr 3, 2013
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Serbia
    cPanel Access Level:
    Root Administrator
    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:

    Code:
    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:
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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:

    Code:
    iptables -I OUTPUT -s 127.0.0.1 -m string --string "domain" -j DROP
    Thank you.
     
  5. webmasteryoda

    webmasteryoda Active Member

    Joined:
    Apr 3, 2013
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Serbia
    cPanel Access Level:
    Root Administrator
    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:
    Code:
    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.
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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:

    Code:
    iptables -L --numeric --line-numbers |grep yahoo.com
    To delete it, simply run this command:

    Code:
    iptables -D INPUT 123
    Replace "123" with the line number from the first result.

    Thank you.
     
  7. webmasteryoda

    webmasteryoda Active Member

    Joined:
    Apr 3, 2013
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Serbia
    cPanel Access Level:
    Root Administrator
    Suggested command returns this:
    Code:
    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... :)
     
  8. webmasteryoda

    webmasteryoda Active Member

    Joined:
    Apr 3, 2013
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Serbia
    cPanel Access Level:
    Root Administrator
    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.

    Code:
    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.
     
Loading...

Share This Page