Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

SOLVED Accept mail from certain TLD's only block everything else

Discussion in 'E-mail Discussion' started by ampapa, Mar 31, 2019.

Tags:
  1. ampapa

    ampapa Member

    Joined:
    Mar 14, 2018
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    US
    cPanel Access Level:
    Website Owner
    Is it possible using CPanel to accept email from only the following TLD's (com|net|org|int|edu|gov|mil|coop|us) and reject everything else?

    This seems like it should be relatively easy to do but I've searched the internet and the forums and am coming up blank with specific instruction on how to accomplish this feat...

    Thanks for any information you can provide.

    ampapa,
     
  2. keat63

    keat63 Well-Known Member

    Joined:
    Nov 20, 2014
    Messages:
    1,266
    Likes Received:
    86
    Trophy Points:
    28
    cPanel Access Level:
    Root Administrator
    Pretty easy from a domain side using Global Filters.
    Login in to the domain Cpanel, create a global filter based on 'from ... does not end with'
    or 'from .......does not contain'
    A little experimentation I'm sure you'll achieve what you want.

    On a server level, it's probably a little more complex, but as a website owner, you won't have access at server level.

    Global Email Filters - Version 76 Documentation - cPanel Documentation
     
  3. ampapa

    ampapa Member

    Joined:
    Mar 14, 2018
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    US
    cPanel Access Level:
    Website Owner
    Appreciate the reply.

    When creating a Global/User filter on the account I understand the accept 'from' concept but that creates a problem. The mail needs to follow one of the "Actions" listed below:

    Email Filter Action Rules
    Discard Message Deletes the message with no Failure message.
    Redirect to Email Sends the email to another email address.
    Fail with Message Deletes the email and sends a failure message..
    Stop processing rules Does not run any filter rules.
    Deliver to folder Sends the email to a specified folder.
    Pipe to program Sends the email to a program or script on the server.

    The only one that seems to apply is "Discard Message" but that would mean I would have to list each TLD "I DO NOT" want to accept mail from and that would be silly and not very useful.

    What makes more sense is to accept mail from those TLD's I DO WANT mail from, that list is posted earlier, and none of these actions appear to allow the mail to further be tested it has to be directed to a certain mail box, again not useful.

    I don't think a 'from' filter is going to work.

    I need to filter TLD's and continue with mail processing, how do I do that?

    ampapa,
     
  4. keat63

    keat63 Well-Known Member

    Joined:
    Nov 20, 2014
    Messages:
    1,266
    Likes Received:
    86
    Trophy Points:
    28
    cPanel Access Level:
    Root Administrator
    If you create a filter "If from does not end with .com" - "Discard message", then anything coming from .biz would be discarded as it doesn't end with .com

    something like the attached image ??
     

    Attached Files:

  5. ampapa

    ampapa Member

    Joined:
    Mar 14, 2018
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    US
    cPanel Access Level:
    Website Owner
    I get the following when testing the filter... it matched something and was deleted.

    here is the test data:
    Code:
    To: test5@example.com
    From: tes5@example.com
    Subject: test
    
    This is a test message.
    
    
    
    The Filter has matched the following condition(s): 
    (((((($header_from: does not end .com or $header_from: does not end .net) or $header_from: does not end .org) or $header_from: does not end .int) or $header_from: does not end .edu) or $header_from: does not end .gov) or $header_from: does not end .mil) or $header_from: does not end .us
       ((((($header_from: does not end .com or $header_from: does not end .net) or $header_from: does not end .org) or $header_from: does not end .int) or $header_from: does not end .edu) or $header_from: does not end .gov) or $header_from: does not end .mil
       (((($header_from: does not end .com or $header_from: does not end .net) or $header_from: does not end .org) or $header_from: does not end .int) or $header_from: does not end .edu) or $header_from: does not end .gov
       ((($header_from: does not end .com or $header_from: does not end .net) or $header_from: does not end .org) or $header_from: does not end .int) or $header_from: does not end .edu
       (($header_from: does not end .com or $header_from: does not end .net) or $header_from: does not end .org) or $header_from: does not end .int
       ($header_from: does not end .com or $header_from: does not end .net) or $header_from: does not end .org
       $header_from: does not end .com or $header_from: does not end .net
       $header_from: does not end .net
    
    The folowing regex appears to be working... thanks for your idea.

    .*@.*\.(?!(.*\.)?(com|net|org|int|edu|gov|mil|coop|us))
     
    #5 ampapa, Apr 1, 2019
    Last edited by a moderator: Apr 1, 2019
  6. keat63

    keat63 Well-Known Member

    Joined:
    Nov 20, 2014
    Messages:
    1,266
    Likes Received:
    86
    Trophy Points:
    28
    cPanel Access Level:
    Root Administrator
    Now that it works, in the short term I would be tempted to deliver the unwanted ones to a specific folder instead of discard.
    At least until you are happy that you didn't miss something important.
    Typical that the most important email you ever needed would be dropped . o_O
     
  7. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,301
    Likes Received:
    2,155
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Thanks for sharing the outcome! I've marked this thread as solved.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice