Home » Exchange Server » Using Transport Rules to Restrict Users from Sending Email to External Recipients

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).

 

Paul is a Microsoft MVP for Office Servers and Services. He works as a consultant, writer, and trainer specializing in Office 365 and Exchange Server. Paul is a co-author of Office 365 for IT Pros and several other books, and is also a Pluralsight author.
Category: Exchange Server

70 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.

      • Farooque says:

        Paul,

        Why Exchnageonline accepts SMTP connection on port 25? This can used for spoofing and yes, we can spoof any email address using this port just by telnet session. Is ther a way in office365 to block port 25 for incoming?

    • 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?

    • 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. Christian 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. Concetta 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

    • 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?

    • 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.

  19. Jody says:

    Is there a way to restrict sending to multiple external domains from the same email? ie, sending to @a.com would be fine, sending to @b.com would be fine, but sending to both @a.com and @b.com from the same email would trigger a rule.

    • Transport Rules are very flexible, you can set multiple conditions and exceptions. I encourage you to work through the new transport rules wizard and find the combination that suits your needs.

  20. Jay says:

    Hi Paul,

    Nice article, I’ve used this method for a while, but have just run hit the 8k transport rule limit so can’t add any additional domains.

    Do you know a way around this?

    Thanks

    Jay

  21. Marks says:

    Hi, I am wondering if someone can help…I am looking to restrict some sets (about 200) distribution group from sending externally but doesn’t want to set up an individual transport rule but a rule to deny these distribution groups. It will include To, CC, BC too and in MS exchange 2010.

    Any idea will be well appreciated.

    Thanks

  22. Marks says:

    Thanks Paul,

    Please can you help with some syntax to go about it and point me to the right direction to help in accomplishing this?

    Thanks

    Marks

    • Transport rules can have many different conditions, and they can have many different exceptions.

      If you launch the new transport rule wizard you will be able to examine the conditions and exceptions to suit your scenario.

  23. Arivazhagan says:

    Dear paul i want to block mails from other domain to a particular group in my org. The members of particular group should receive only internal mails. is it possible. please help

  24. basavaraja says:

    I have installed the exchange 2016 preview. Able to login successfully on mobile device and owa. But not able to send emails either to same user or different user.

  25. Steve Kendall says:

    I am curious about something. We have a vendor that has changed companies. We realize that many people have her old email address in outlook. We have asked people to not email the old address but to email her new one. Apparently not everyone is paying attention. Is there a way in Exchange that I can either block the old email address of the vendor so my staff cannot send to it or redirect emails my staff sends to that old address to this vendors new address.

    Thank you!

  26. njaay says:

    Hi
    is there a way to drop a email sent to an address that doesn’t exist in AD, from a rule in Exchange 2010
    This email is used by an application for room reservation, when we validate an invitation, there is a NDR, because this adress doesn’t exist.
    Thanks for your help

  27. Nagendra says:

    Hi Paul,

    Can we do some customization like, if the sender is sending emails to a particular domain like ‘user@gmail.com’, he cannot send it unless he copies someone in the parent orgranization like ‘user@myorg.com’

    • Maybe. Take a look at the conditions and actions in transport rules and see if you can construct a rule that does that. Or, you could use moderated transport so that when that person sends to the particular domain a moderator has to approve the message.

  28. Seelan says:

    Hi Paul, i would like to check if there is any other possible way to perform the same for inbound emails.
    External users –> internal users = blocked
    External users –> Distribution group –> internal users = allowed

    understand transport rules process rules on the message by inspecting the headers or envelope.

  29. Brindha says:

    Hello Paul

    Sorry its an old thread but I have one question regarding the above topic. Exchange 2007.

    I want my users to not send mails to invalid domains (internal and external).

    I am trying to create a transport rule like this:

    Apply rule to messages when “message header” contains “specific words”

    Case 1- Mails are blocked and NDR thrown to sender when

    Message header= to

    Specific words = full email address of the invalid recipient

    Case 2- Mails not blocked when

    Specific words = @domain name , *@domain name

    Why it accepts email address but not the domain name . I have many such invalid domain names to which my users are sending mails.

    Regards
    Brindha

  30. GEORGE TSOUGARAKIS says:

    Hi Paul

    GREAT ARTICLE!! I’m tempted to try this but looks like I may get myself in trouble if I implement this for what I need. I searched and searched but no one can offer this particular solution to my problem.

    I have a customer with Exchange 2007, *there are 4 domains in the “accepted domains” and only 1 send connector. Please forgive me if some configurations sound nuts, I inherited this customer due to the other IT Company dropping the ball. We have them now…

    Out of all 4 domains, we realized they are being spoofed and hundreds of emails are leaving this firm and hitting other recipients. People are complaining… If there was a way to STOP the sending of emails from these three domains (just sending because they still receive emails which are forwarded to the 4th domain thats in good standing) and keep the 1 live would be the solution of the century for me. Any thoughts??

    • Are the spoofed emails originating from your server? Normally they are sent by spammers using compromised servers and PCs on the internet. If the emails are actually going from your server that’s not really spoofing, that’s more like your server has been compromised or is allowing open relay.

      • GEORGE TSOUGARAKIS says:

        Hi Paul

        Thank you for your response. So much appreciated Sir. I really don’t know and I’m in a tough place. Have to try and figure this out by the time they come back to work on Monday. Sorry that I’m exploring this out on Thanksgiving-eve…

        As far as we know, recipients are receiving emails (like 100-300) from this organization (my customers domain) and my first approach was to disable 3 of the 4 domains SMTP policy within exchange. Can this be done. Never ever had to do this with anyone.

        Im open for your thoughts. Been following your threads for a while and know you have great solutions.

        Thank you 0:-))

        • You really need to determine whether your server is the source of the messages or not. If someone is complaining to you, get them to attach (not forward) a copy of one or two of the messages and send them to you. Look at the message headers (use mxtoolbox or the exrca.com header analyzer) to see where they are originating from.

          If the messages are originating from the server, then you need to do further investigation to work out how they are being sent. There are online tools (again, mxtoolbox is one of them) that can test your server to see if it’s an open relay. Or you can run message tracking log searches to trace the source of the messages.

          If the messages aren’t originating from your server, they’re likely being sent by spammers on the internet who are spoofing your domains. In that case, you should look at implementing SPF records for your domain.

          There’s no point panicking and making changes (like trying to disable domains) without understanding the root cause of the problem first. Investigate properly, find the problem, and take sensible steps to implement a solution.

  31. Tarun says:

    Hello Team, I need help on this.

    we have exchange server 2003, and one of user keep sending emails to unwanted ids

    How to get restrict these emails.

    Tarun

    • Mohamed Mahmoud says:

      Please i need a help
      i have exchange 2010 . and i got spam mails send to specific users some of them exist and other was in my users and deleted . so, i need help to how create transport rule to delete the message itself (don’t reach to anyone from recipients send to )if one of recipient is ………

      Thank You
      Mohamed Mahmoud

Leave a Reply

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