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!

Global Filter- Fail with Message filter not working properly

Discussion in 'E-mail Discussion' started by Salman Arshad, Jul 5, 2018.

  1. Salman Arshad

    Salman Arshad Registered

    Joined:
    Jul 5, 2018
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Islamabad Pakistan
    cPanel Access Level:
    DataCenter Provider
    Hello i am trying to avoid emails from certain people. I want the server to reject the email and tell the unwanted sender something like "mailbox full blah blah".

    I tried using the global filter from cpanel "Email Filters" > Create new filter
    Rules: From > contains > temp@abc.com
    Actions: Fail with Message "Mailbox is full / Blocks limit exceeded / Inode limit exceeded"

    it works on my me@abc.com i do not receive te email and temp@abc.com gets the error message.
    However the problem is when i tested this filter with a gmail or Hotmail or even a cpanel domain the fail message is not received(by the sender) on gmail or Hotmail or whatever domain other than my own.

    Conclusion: Fail message is not being received(by the sender) when an filtered email from another domain is sent to me.

    Help :(
     
  2. keat63

    keat63 Well-Known Member

    Joined:
    Nov 20, 2014
    Messages:
    1,001
    Likes Received:
    44
    Trophy Points:
    28
    cPanel Access Level:
    Root Administrator
    i cannot comment why you don't see the fail message.
    But 'contains' is probably not the right way to go.

    Many words could contain temp@, maybe equals would be a better option if you wish to block a particular email address.
     
  3. cPanelLauren

    cPanelLauren Forums Analyst
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    2,758
    Likes Received:
    187
    Trophy Points:
    143
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    HI @Salman Arshad

    I tested this the way you have it configured with my Gmail account and found that I did in fact receive the failed message but it was sent to spam when it was received.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Salman Arshad

    Salman Arshad Registered

    Joined:
    Jul 5, 2018
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Islamabad Pakistan
    cPanel Access Level:
    DataCenter Provider
    I tried everything but it does not work :( not even in spam/trash or junk.

    there is also an option in horde filters but when I try to choose the action it does not give the option in the drop down "reject with message" any way to use that?
     
  5. cPanelLauren

    cPanelLauren Forums Analyst
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    2,758
    Likes Received:
    187
    Trophy Points:
    143
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hi @Salman Arshad

    For me contains worked also I got it to function using equals but you need to consider the entire "From" line when using equals. For example when I send mail from my Gmail account to my test server my "From" line is not just my email address:

    Code:
    From: Lauren <myemail@gmail.com>
    Date: Wed, 11 Jul 2018 09:28:35 -0500
    Message-ID: <CAF7rb1JAegpgXhQT7R7O6z3rmvK5Mb58XV7OJNZiSXMXSnwQ8w@mail.gmail.com>
    Subject: another test
    To: test@mydomain.tld
    In order for this to work as equals you'll need to add that entire from line:

    Code:
    [root@server test]# cat filter
    # Exim filter - auto-generated by cPanel.
    #
    # Do not manually edit this file; instead, use cPanel APIs to manipulate
    # email filters. MANUAL CHANGES TO THIS FILE WILL BE OVERWRITTEN.
    #
    
    headers charset "UTF-8"
    
    if not first_delivery and error_message then finish endif
    
    #test
    if
     $header_from: is "Lauren <myemail@gmail.com>"
    then
     if error_message then save "/dev/null" 660 else fail "Test Fail" endif
    endif
    I can also get this to work for contains which is going to just ensure that the string "myemail@gmail.com" exists in the header in the "From" section.

    Code:
    [root@server test]# cat filter
    # Exim filter - auto-generated by cPanel.
    #
    # Do not manually edit this file; instead, use cPanel APIs to manipulate
    # email filters. MANUAL CHANGES TO THIS FILE WILL BE OVERWRITTEN.
    #
    
    headers charset "UTF-8"
    
    if not first_delivery and error_message then finish endif
    
    #test
    if
     $header_from: contains "myemail@gmail.com"
    then
     if error_message then save "/dev/null" 660 else fail "Test Fail" endif
    endif
    I've confirmed multiple times at this point that the filter does indeed work, if it's not working for you, you may need to rule out other factors such as other filters or configurations.

    The mail transaction at /var/log/exim_mainlog will show you when it's working as well - most importantly this line:

    Code:
    2018-07-11 14:36:38 1fdGEQ-0002vE-6z ** test@mydomain.tld R=virtual_user_filter: Test Fail
    Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,750
    Likes Received:
    111
    Trophy Points:
    343
    cPanel Access Level:
    Root Administrator
    I really don't recommend using fail in filters. This is really a horrible idea that I wish cPanel would remove.

    If someone sends an email from idontexist@example1.tld to imafilteredaddress@example2.tld and it hits a filter that fails the message, then the mail server handling mail for example2.tld is going to try to send a failed email message back to idontexist@example1.tld but it's not going to go anywhere because idontexist@example1.tld ... doesn't exist.

    Set up an example1.tld account on one server, don't create any email addresses and leave the default address as :fail: on that account.

    Set up an example2.tld account on another server. Create a filter that matches a subject of "fail me" and set it to fail the message.

    Set up an email account on example2.tld - imafilteredaddress@example2.tld

    Now send a message from idontexist@example1.tld with the subject "fail me" to imafilteredaddress@example2.tld.

    imafilteredaddress@example2.tld won't get the message.

    But idontexist@example1.tld won't get a failed message back.

    In fact, if you review the mail queue on the example2.tld server, you'll find that failed message stuck in queue waiting to be sent to idontexist@example1.tld but it never will because it doesn't exist.

    You can't use :fail: on messages that have already been accepted by the server.

    :fail: works in the default address because the message is never accepted by the server. When doing an SMTP transaction and you leave that "." on a line by itself... the message fails if the recipient does not exist and the account's default address is set to :fail: ... the server never accepts it.
     
    rpvw likes this.
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