Using Transport Rules to Restrict Users from Sending Email to External Recipients

I frequently see questions such as this one about how to restrict users on the network from being able to send emails to external recipients.

I actually wrote an article on the subject about four years ago, though it deals with one specific scenario of “deny most, allow some”, and even though it was written when Exchange Server 2007 was the latest version it still demonstrates how Transport Rules can be used to achieve various restrictions on what email senders can do.

In this article I will specifically answer the question of how to restrict a small number of specific users from being able to send emails to recipients outside of the organization.

The first step in this method is to create a distribution group. The members of this group will be the users who are restricted from sending external emails. It does not need to be a security group, but it does need to be universal in scope.

Next, create a new Transport Rule with the following configuration.

Conditions:

  • From a member of a distribution list (and choose the distribution group you created above)
  • Sent to users that are inside or outside of the organization, or partners (and choose “Outside”)

Actions:

  • Send rejection message to sender with enhanced status code (I set the status code to 5.7.1 and configure a message such as “You are not authorized to send email to recipients outside of this organization”)

Exceptions: (optional)

  • Except when a recipient’s address matches text patterns (and add any domain names or email addresses they should still be allowed to send to)

After the new rule has taken effect the members of that distribution group will not be able to send to external recipients, whether they use the To, CC, or BCC fields to do so, and will still be able to send to those domains or email addresses you configure as an exception to the rule (even if the message includes other recipients that will get blocked, the permitted ones will still receive the email).

 

Comments

  1. Trevor says

    Paul

    Great article, i only wanted a specific user to be able to send internal emails. I followed your instructions to the T and they worked perfectly, however i have now removed the specific user from the distribution group (only user in the group) but it still blocks any outgoing emails, i have logged the user off and on again, restarted the pc, re-added a dummy account to the dissolution group, logged the user off and on again and waited for a couple of hours and its still being blocked.

    Is there a period of time for how long it takes to update all the setting in Exchange 2010 SP2 and 2008 R2 AD when removing users from distribution groups?

    Also for another user is it possible to block specific email address and domains.

    Thanks
    Trevor

      • Trevor says

        Thanks for the reply and yes all is working as normal after the 4hrs. Not sure if its possible to lower the refresh time from 4hrs to 5mins.

        Thanks
        Trevor

        • Jaime says

          In order for changes to take effect immediately, you must restart the Microsoft Exchange Transport service under services.msc where you have the Exchange server running. You should the change take effect after the service finishes restarting.

    • tom says

      Hi Paul,

      How can I configure it in 2007 Except when a recipient’s address matches text patterns option is not available there in exchange 2007 .Is there any option to add this in exchange2007.
      Because of the same users can able to send mails to external world if they put it in cc or bcc.

  2. Joerg Renggli says

    Hi Paul,

    Is it possible to Limit the “Maximum numper of recipients” only on outgoing Mails, but not for internal Mails?

    Thanks you
    Jörg

  3. John says

    Forgive my denseness, but is there a way to set a user up so that they can only send emails to one specific external domain?

    We have students from an external organisation who need to send timesheets back to their host employer. I have currently got one of our email address for them to use but I don’t want them to be able to send anywhere else other than anyone at “blah.com”.

    Is there an easy way to do this?

    • says

      Transport rules should allow you to do this. Each rule has a criteria, action, and exceptions. So the criteria would be “From user X” (or a group), action would be “Reject” or similar, and exceptions would be “Unless recipient is in domain Y”.

      I’m only vaguely describing it there, but if you explore the New Transport Rule wizard and do some testing you’ll see what I mean.

  4. MK says

    Hi Paul,

    I have the rule and want to add 200 members to restrict sending emails to internet. Instead of adding users i am planning add one securtiy group and merge it in to existing Group which is being used by transport rule for external email blocking.

    Please suggest me what happened if we add groups in TR instead of users. Will TR takes time to process the action?

  5. Thi Han says

    I’m just a new here.
    I want my DL of exchange user sending to specify domain.
    e.g; i want some DL to allow ” *@abc.com ” ” *@123.com ”

    With my regards,
    T.Han

  6. Brent says

    Paul

    That was very useful as I am now able to configure and edit the transport hub effectively.

    But I am now looking to configure the relay to restrict/allow mail from my code but i am getting the following error

    I get this error message: ‘Mailbox unavailable. The server response was: 5.7.1 Unable to relay’

    Brent

  7. Oliver says

    Hey Paul,

    is it possible to get the powershell command for that ? We wanna deny one user in one specified org to send emails.

    Greetings Oliver

  8. Tom says

    ■Except when a recipient’s address matches text patterns option is not available there in exchange 2007 .Is there any option to add this in exchange2007.

  9. VC says

    Thanks for sharing this, Paul. Any links or pointers that you can share, to add custom rules via C# or something ,would be helpful. Am looking to create a new custom rule that looks for specific patterns in the to and from email addresses.

    Thanks

    VC

  10. says

    Dear Paul,

    is possible to deny permission to send outside the organization for a user not owner of the mailbox but that has ‘send as permission’?
    We have a transport rule for deny permission to send out for user in a specific group but if an user has ‘send as’ permission for a mailbox whose owner isn’t in the group he can send out from this shared mailbox, and we want to avoid this situation.
    Thank for any suggest!

      • Christian says

        Thanks Paul,

        but is not a problem about trusting or not a user but just be aligned with a organization policy. The annoying thing is that in 2003 ( before migration to 2010) the ‘delivery restriction ‘ setting in the SMTP connector did exactly what we wanted: the delivery restriction deny all except who is in a security group. With this configuration only the user in the group can send (with ‘send as’ permission’) outside from a mailbox it does not own.
        My guess is that in exchange 2003 the ‘smtp delivery restriction’ looked permissions not only for the owner of the mailbox but also the ‘send as’ or ‘on behalf to’ user permissions.
        This behaviour is changed in 2007/2010 with transport rules but there is no technical explanations from Microsoft documentation of this change.

  11. says

    Hey there I am so thrilled I found your site, I really found you by
    error, while I was browsing on Google for something else, Nonetheless
    I am here now and would just like to say thanks a lot for a marvelous post and a all round
    entertaining blog (I also love the theme/design), I
    don’t have time to read it all at the minute but I
    have bookmarked it and also added in your RSS feeds, so when I have time I will be
    back to read much more, Please do keep up the superb job.

  12. Nick says

    Hi Paul,

    Thanks for sharing. However I am having the same problem as Tom, I couldn’t find the “Except when a recipient’s address matches text patterns option” in my Exchange 2007 Version: 08.03.0298.001.

    I want to restrict a user to send email to certain email address only.
    I’m currently using “except when a text pattern (xxx@xxx.com) appear in a message header (TO)” but it doesn’t perfectly meet my requirement.

    Appreciate if any help can be provided.

  13. Nick says

    Hi,

    To elaborate further, it does not meet my requirement because from what I have tested,
    this text pattern exception will allow the email to go thru when there are multiple recipients, and one of them is permitted.

    Thank you.

    • Marty says

      I agree with Nick…

      The user can simply CC themselves and send to any external recipient. The rule doesn’t trigger because one of the “users” is internal, so pretty easy to get around.

      Thanks.

  14. Sundaresan says

    I have set this transport rule. But the thing is, if i give individual email id, the mail gets blocked for that user to external domains immediately i click apply for the rule settings. But if i do this for a distribution group, it does not apply this rule and i didn’t get any bounced mail. Mail gets delivered successfully.

    So is the delay what you talk about is for applying rule from a distribution group? but not for an individual id?

    • Sundaresan says

      I got it. Its the same 4 hrs frequency applied even for the first time when we add any user to a distribution group.

      Only individual mail id rules are applied instantly..

      Thanks..

  15. Jon says

    Is there a power shell command that will hide all distro groups within the GAL or deny the sending to all Distribution Groups from 1 Distribution group?

    In other words, I have 1 Distribution group, that I do not want to be able to send to any other Distribution groups, nor do I want them to see Distribution Groups within the GAL.

    Thanks

    • says

      You can use transport rules to create ethical walls between DLs.

      GAL visibility is a different matter. You would probably need to use Address Book Policies to achieve what you’re asking for there.

  16. Jay says

    This question isn’t about a transport rule per se, nor am I an administrator… Our company is implementing a policy that we should notify IT before (or at the same time as) sending any email outside the organization. They won’t block the email, they just want to be notified about it and add it to some report they will publish.

    Trying to play along, I’d like to create a local rule on my personal outlook account that effectively “warns” me each time I try to send an email outside the organization, i.e. as (or after) I send an email outside the company I receive a reminder such as follows: “The recipient of this email is outside the company. Remember to notify IT about the recipient.”

    I’ve cobbled a rule together that works for recipients INSIDE the company, but can’t figure out how to write a rule for EVERYONE BUT INSIDE the company.

    Thoughts, solutions or suggestions?

    • says

      LOL! My thoughts are that this is one of the most ridiculous IT policies I have ever heard of. I can barely believe your IT department is putting this burden on you.

      A solution is for your IT department to use the tools at their disposal to extract data from email logs to produce their report.

      My suggestion to you is to tell them to do their job and not bother you with rubbish like this :)

        • Jay says

          I’m with you…

          I agree this situation sounds absurd, but if you knew the WHOLE background you might have a little more compassion (grin). I’ll try to be brief… I work in Shanghai for a Chinese financial institution with multiple sub-entities. In total there are over 100,000 employees working on multiple different platforms all over the country. Outlook is by no means a standard. Our subsidiary has about 8,000 employees, only some of whom use Outlook.

          Amid China’s urgent anti-corruption efforts (a good thing) the Chinese Government has decreed some immediate high-level requirements – announced in our company yesterday, effective today – to avoid inappropriate sharing of info with outside entities. For now there is no limitation as to WHO you can send to (and hopefully there won’t be – in our situation that would be REALLY ridiculous!), just a requirement to track external recipients in the event some case of corruption is discovered in the future. Per requirements I’ve already provided a list of domains I’m likely to send to, but there will always be unexpected recipients.

          As governments do, there is little regard for how easy these (wacky?) requirements can be accomplished. No doubt IT will find a satisfactory solution and implement it in time, but I’m still burdened with abiding by the rules starting today. In the end it is each employee’s responsibility – I’m just trying to find a way to help me avoid accidentally forgetting to update the list after I send an email to a person or domain not originally on the list.

          So to summarize and restate, my end user requirement (regardless of how crazy) is to create a local rule on my personal outlook account that “warns” me each time I try to send an email outside the organization, providing a reminder such as “The recipient of this email is outside the company. Remember to notify IT about the recipient.”

          If I can just figure out how to filter out non-inhouse domains, I “think” I can write a rule to send a copy of only those emails to a special folder, then another rule that alerts me everytime that folder receives a new email. Could it be that simple? If so, question is how to filter out non-inhouse domains….

          Whew…

  17. Jason says

    I have a situation where I want to block emails being sent to external addresses on the conidtion that the email is sent from a particular internal server.

    We have a test server for a app we are developing and want to allow the server to relay through Exchange for internal email (For Testing). But we want to restrict the test server from emailing outside of our organisation.

    Is this possible?

    • moonwick01 says

      Yes you can do that, within the Transport rules, the rule would be similar to this,

      Apply this rule if…

      The recipient is located… Outside of the organization

      and

      the sender is this person… “service account AD account name/Email address” (you can also use the sender is a member of, if you have a distro goup setup)

      Do the following…

      Block the message… Delete the message without notifying anyone

      save it, restart your service, or do a dirsync if your in the cloud and all external emails will be blocked for that user or group. if you want to know if it is trying to send outside- see below.

      click add action and choose

      Redirect the message to… these recipients and pick an account to send it to.

      Hope this was helpful.

      • Jason says

        Thanks for your reply.

        So the rule should work the same as the article as long as I put the AD Computer Account in the distro group?

        I will try it out and post back my results.

  18. John says

    Alternative end point solutions are available that asks users to confirm external recipients. Some products that does this are SafeSend and SperrySoftware.

Leave a Reply

Your email address will not be published. Required fields are marked *