How to remove X-Ham-Report from message header
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 :-) )
-
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: #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.0 -
Mailing List Archive: remove_header not working? contains a report of similar failure of this method (without reaching much conclusion). It does suggest using report_safe 0 which I have tried, but still no results. 0 -
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: #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.0
Please sign in to leave a comment.
Comments
3 comments