Rejecting message based on email header ( in Office365 )

Copper Contributor

I have a very simple 'mail flow' rule which states that exchange should reject a message when it sees an email that has a header set to a specific value. The rule is in active/enforced mode but I can't get it to work.

 

My guess is that exchange is unable to find or match the header (Although the test email I am sending has header set to correct value).

 

I have tried that same (rejection) rule for the 'subject' field and it worked as expected. I am using custom/non-standard header named "Action" but its a valid mail/mime header.

 

Attached is the screenshot of the rule.

 

Thanks.

9 Replies

Hello @Ramu Denduluri,

 

Where does the header get added in? Is this being done by a third party system or server before it is reaching O365, or is this being done by the client of the users.

 

My first though was if this is being done somewhere for the users, it may be the case that the header value is not there when it is being processed through the edge/gates for your users.

 

I have had success searching for "x" headers, which I know are added in, so I would be a bit surprised if it was missing it. 

Would you be able to post atleast the part of the header the action section is included in for our curiosity sack.

 

Also it sounds like you have done some good due diligence, this might be one of the cases where you ultimately have to open up a premier case with Microsoft, as there is only so much we here on the forums can do without access to the actual servers. Most of our talk and suggestions are going to be speculative/based on our own experiences. Atleast to me in this case you seem to be pretty thorough in what you have done and tested, I am not sure how much we can find out without getting our hands dirty so to say.


Adam

 

Hi Adam,

 

Header is being added by smtp client (Header name is Custom-Header in this particular case and value is block, I have adjusted my rule to reflect the correct header name).

Below is snippet from smtp client logs:

--------------

Message-ID: <425255836.1.1540471453322.Mail.user@host>
Subject: This is test subject
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Custom-Action: block

This is test email body.
.
250 2.0.0 OK <425255836.1.1540471453322.Mail.someuser@somehost> [Hostname=MWHPR14MB1135.namprd14.prod.outlook.com]

--------------

 

When the recipient receives email (which it should not if rejection rule works correctly) I can see mail headers in  outlook File > Info > PropertiesInternet headers,  I do not see my custom header. Exchange seems to be stripping / rewriting headers. But is it stripping the header before running through transport rules, I have no way of knowing.

 

Btw- I can confirm that I have seen the same rule hitting atleast once (couple of days ago) but it stopped working the next day (I don't remember making any config changes in between). After it stopped working, no matter what I do , rule would not match . I have removed all transport rules, connectors etc and just kept this single rule to make sure there are no conflicts.

 

Thanks for your help, I would like know what is the best place to post this question ?

 

Regards.

If you telnet on port 25 to a mail server of your choice and manually send a test message with that header, does it show up? 

Hi Andy,

 

I tested sending email to a different smtp server using javamail client with header set and the header shows up on the other side. The same email client I used for testing with Exchange online just to be consistent but no avail.

 

Thanks

Hmmm,

 

Well you hit all the information on the head, thank you for being through in your response.

 

It does sound like that line is being stripped. Why I dont know. I have had issues in the past where things like this happened, and ultimately through a long escalation found out some change was made at O365 that was never published because it was considered a small thing.

 

I think you are going to need to open up a case with premier support, show them these details, and see if the support tech can reach out to product to give you more information as to why.

 

Sorry I am not of more help, but you are covering all your basis. To me you need to talk to someone on the back end of the receiving servers at Microsoft.

 

Adam

Did you test with telnet on port 25 sending to Office 365? Remove the client from the equation just to see.

Hi Ramu,

This will not work, as you are trying to block an email using a Custom header which is generated by a Java Email Application. Custom Headers does not fall under predefined rules in Transport for Office 365 as far as I know. You can reach support, however, i know their answer. These things does not fall under Office 365 scope.

 

Thanks,

Rishank Ganguly

Hi Rishank,

 

I have already reached out to support. They said they will look into the issue.

 

Any idea if it would work for headers such as Message-Id or Content-Type . These are typical headers that every message includes. I have verified it work for From and To headers, but there are specific rules for such fields (from/to/cc/bcc/subject). You can guess that Exchange treat these as fields, not headers. Then why provide rules which talk about mail headers, just wondering.

 

Thanks for your help. 

Hi Ramu, 

You are right, Exchange treats all these as typical headers, and they accept values from any email systems. So these can be treated as Fields. Now, there are some X-MS headers which accepts certain values. Check this article if it helps:

https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-provision-x-...