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!

custom exim filter for incoming mail

Discussion in 'E-mail Discussion' started by amjad.q, Mar 18, 2018.

Tags:
  1. amjad.q

    amjad.q Member

    Joined:
    Jul 2, 2016
    Messages:
    22
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    India
    cPanel Access Level:
    Root Administrator
    I would like to add a custom exim filter files for incoming mail which has a link with "php?" then delivered it to spam folder or mark it as spam like give it a spam score

    I can't use the SpamAssassin for that becouse the SpamAssassin doesn't scan the mail which has a big size , no recommended to make the SpamAssassin scanning large messages that can lead to increased CPU or memory usage


    so the exim filter look like below , but I couldn't complete its wording to do what I need

    ===================
    #links with .php & html - roul
    if
    $message_body contains ".php?"
    and $message_body contains "http"
    then
    .........
    endif
    ===================

    Thanks
     
    #1 amjad.q, Mar 18, 2018
    Last edited: Mar 18, 2018
  2. 24x7server

    24x7server Well-Known Member

    Joined:
    Apr 17, 2013
    Messages:
    1,880
    Likes Received:
    89
    Trophy Points:
    78
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hi,
    You can use /etc/antivirus.empty file to check if you are get use it for your benefit. I happen to not find appropriate link because of some restrictions on this forum. However, if you search for antivirus.empty file in Google, you can get the parameters that you can put to test..
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. amjad.q

    amjad.q Member

    Joined:
    Jul 2, 2016
    Messages:
    22
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hello,

    Thanks 24x7server , After searching about antivirus.exim I reached to the same point , I can write the condition but I can't write how to make it do what I need ( delivered it to spam folder or mark it as spam like give it a spam score )

    Code:
    if
    $message_body contains "http" and
    $message_body contains "php?"
    
    then
    ........
    endif

    anyone can advise
     
  4. keat63

    keat63 Well-Known Member

    Joined:
    Nov 20, 2014
    Messages:
    1,017
    Likes Received:
    45
    Trophy Points:
    28
    cPanel Access Level:
    Root Administrator
    would 'then fail' not do what you want ?
     
  5. amjad.q

    amjad.q Member

    Joined:
    Jul 2, 2016
    Messages:
    22
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    India
    cPanel Access Level:
    Root Administrator
    I wouldn't make them fail , I want delivered to spam folder
     
  6. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    I believe you'd want to use the "Deliver to Folder" filter action. EX:

    Code:
    save "$home/mail/$domain/$local_part/.Spam/" 660
    Note the ".Spam" folder would need to exist under all accounts for this to work, so you'd need to ensure that occurs. There's a thread on that topic at:

    Deliver Spam to Spam folder, globally

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    amjad.q likes this.
  7. amjad.q

    amjad.q Member

    Joined:
    Jul 2, 2016
    Messages:
    22
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hello,

    I have tested it but it didn't work with me , the mail didn't deliver at all , not to inbox or spam box ,Even when I checked the Mail Delivery Reports the email not exist



    The Spam Box is enable and the .spamassassinboxenable file already exist and the spam box show in the email window , But when I check the email files there 3 files only (cur , new and tmp)

    below the rule which I used

    Code:
    if ("$h_from:" contains "email@mydomain.com")
       then
        save "$home/mail/$domain/$local_part/.Spam/" 660
      endif
    Note : the exim filter work with me normal when I use another rule

    Thanks
     
  8. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    These type of custom rules are unsupported. It's possible the custom filter rule needs to be modified further, or you did not correctly setup the filter. Can you verify the specific steps you took to add the filter and then the specific steps you took to test it?

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. amjad.q

    amjad.q Member

    Joined:
    Jul 2, 2016
    Messages:
    22
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hello,

    I have added my file in /usr/local/cpanel/etc/exim/sysfilter/options/ , then I enabled my new filter from Exim Configuration Manager >filters and saved

    Then I have take loot at /etc/cpanel_exim_system_filter , it's show my new rule has been added normal as below
    Code:
    # END - Included from /usr/local/cpanel/etc/exim/sysfilter/options/attachments
    
    # BEGIN - Included from /usr/local/cpanel/etc/exim/sysfilter/options/my_test_rule
    # (Use the Basic Editor in the Exim Configuration Manager in WHM to change)
    # or manually edit /etc/exim.conf.localopts and run /scripts/buildeximconf
    if ("$h_from:" contains "xxxx@gmail.com")
       then
        save "$home/mail/$domain/$local_part/.Spam/" 660
      endif
    # END - Included from /usr/local/cpanel/etc/exim/sysfilter/options/my_test_rule
    
    # BEGIN - Included from /usr/local/cpanel/etc/exim/sysfilter/options/spam_rewrite
    Then I tested to send email from my gmail account which in the rule to email account in my server
     
  10. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    In "WHM >> Exim Configuration Manager", under the "Filters" tab, are you using a custom filter for the "System Filter File" option? If so, you'd need to add your custom filter rules to that custom system filter file itself instead of adding them as separate filter files under the options directory. There's a thread on this topic at:

    Exim custom filter not working

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. amjad.q

    amjad.q Member

    Joined:
    Jul 2, 2016
    Messages:
    22
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Yes , I'm using System Filter File and my filter has been added to cpanel_exim_system_filter as I reported above

    The filter work when I use another action as (fail) ,But when I use the action (save "$home/mail/$domain/$local_part/.Spam/" 660) , I dosn't work

    Code:
    if ("$h_from:" contains "xxxx@gmail.com")
    then
     fail
    The above filter work with me but the below filter doesn't work

    Code:
    if ("$h_from:" contains "xxxx@gmail.com")
       then
        save "$home/mail/$domain/$local_part/.Spam/" 660
      endif
    My problem with the action


    Thanks you
     
  12. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    It's possible that specific rule won't work for the purpose you intend it to. It's only offered as an example submitted by another user at:

    Deliver Spam to Spam folder, globally

    You may want to consider reaching out to a system administrator or posting to the Exim User's mailing list for help developing a custom Exim system filter rule that does what you need it to do, as it's typically outside the scope of support we can provide:

    System Administration Services | cPanel Forums
    Exim-users Info Page

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. amjad.q

    amjad.q Member

    Joined:
    Jul 2, 2016
    Messages:
    22
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hello,

    what about if can do the purpose by different way , if there action to change the Spam static for example
    Code:
    if ("$h_from:" contains "xxxx@gmail.com")
       then
        X-Spam-Score = Yes
      endif
    OR
    Code:
    if ("$h_from:" contains "xxxx@gmail.com")
       then
        spam_score = 100
      endif
    We just need to make the email be as spam and delivered to spam folder by anyway from the exim filter , so can we control or change the spam static form the EXIM ?

    I wish if anyone have information advise us

    Thanks you
     
  14. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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