Forum Discussion

Ramu Denduluri's avatar
Ramu Denduluri
Copper Contributor
Oct 24, 2018

Rejecting message based on email header ( in Office365 )

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.

  • Adam Ochs's avatar
    Adam Ochs
    Steel Contributor

    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

     

    • Ramu Denduluri's avatar
      Ramu Denduluri
      Copper Contributor

      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.

      • Rishank Ganguly's avatar
        Rishank Ganguly
        Brass Contributor

        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

Resources