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!

How to remove X-Ham-Report from message header

Discussion in 'E-mail Discussion' started by Charles Lindsey, Aug 26, 2018.

  1. Charles Lindsey

    Charles Lindsey Registered

    Joined:
    Aug 26, 2018
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    UK
    cPanel Access Level:
    Website Owner
    I have an incoming message which contains a header I want to remove before passing it on to the addressee (using a Forwarding Rule).

    So I want to create a filter which recognises this is a message I need to fix. and which uses the "Pipe to a Program" option. I then have to provide a script which accepts this message on stdin, but I must not write anything to stdout because that would signify the message was to be discarded. I can easily edit the message to remove the offending header (I would probably use awk), but where do I then output it to so that it gets sent?

    (And if you want to know why I want to remove a header, it is the X-Ham-Report which cpanel inserts after usinfgSpamassassin, and is incompliant with RFC 5322 - but that is another story :) )
     
  2. 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:
    Hello @Charles Lindsey,

    Have you tried making use of the "headers remove" filter action to remove part of the message header instead of handling that through a script? EX:

    Code:
    #HamRemoval
    if
     $header_to: is "test1@email-domain-test.tld"
    then
     headers remove "X-Ham-Report"
     deliver "test2@email-domain-test.tld"
    endif
    Note this will only work as an Exim system filter rule, and requires root access to the server to setup:

    How to Customize the Exim System Filter File - cPanel Knowledge Base - cPanel Documentation

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    #2 cPanelMichael, Aug 28, 2018
    Last edited: Sep 19, 2018
  3. Charles Lindsey

    Charles Lindsey Registered

    Joined:
    Aug 26, 2018
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    UK
    cPanel Access Level:
    Website Owner
  4. 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:
    Hello @Charles Lindsey,

    I performed some additional testing and concluded that it's not possible to remove X-Ham-Report from the email header using account-level and email-level filter rules or custom SpamAssassin rules. Header addition and removal is available only in the Exim system filters (which requires root access to add/edit).

    I did test creating an Exim system filter as "root" and confirmed the following example works as intended:

    Code:
    #HamRemoval
    if
     $header_to: is "test1@email-domain-test.tld"
    then
     headers remove "X-Ham-Report"
     deliver "test2@email-domain-test.tld"
    endif
    The best advice I can provide is to reach out to your web hosting provider to see if they can setup this custom Exim system filter rule on your behalf.

    Let me know if you have any additional questions.

    Thank you.

    Moderation Note: I edited/removed some of the previous posts on this thread to reflect the results of additional testing.
     
    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