Sometimes you come across situations that require a users corporate mailbox to be configured to forward out to an external mailbox account. There are many situations within business organizations that can drive this need.
Before explaining how to configure the forwarding careful consideration should be done regarding the security risks to corporate data and communications by allowing it to automatically forwarded outside the organizations messaging system. This article shares some of the risks that this configuration can introduce.
Mailboxes in Exchange Online can be configured to forward messages to an external email domain. Forwarding can be configured through several different areas within Exchange Online. The user can configure forwarding through Outlook Web Access (OWA) options and administrators can configure this setting directly on mailboxes within the Exchange Online subscription.
For this article we will be focused on the command that can be used through PowerShell. More information on how you can configure email forwarding through OWA or the administrative console is available here. One challenge I have found when using the administrative GUI to configure email forwarding is that it uses a picker window. Using this picker window only allows you to select from items located in the global address list. Using this picker means that you can only select an internal mailbox or mail contact. For some situations the technical requirement may be require forwarding to an mailbox for an external mail domain. In order to satisfy this requirement we are not able to use the GUI administrative tools and need to set this configuration using PowerShell or having the users set this via the OWA options. We will walk through using PowerShell to see how we can achieve this technical requirement with a simple command:
For these examples you must first connect PowerShell to Windows Azure AD. For instructions on this see this article.
To check the current fowarding settings (if any) on the specified mailbox:
Get-Mailbox -Identity email@example.com | FL Name,ForwardingSMTPAddress
With the use of the commands below you are forwarding all emails sent to firstname.lastname@example.org to email@example.com. The command switch -DeliverToMailboxandForward determines if the message should be stored in the mailbox of user firstname.lastname@example.org or not. Setting this value to $true a copy of the message is stored in the mailbox. If you do not wish to leave a copy of the mail in Fred’s mailbox then set this value to $false.
Example 1: Set forwarding email to External recipient and save a copy of the message in the forwarding mailbox
Set-Mailbox -Identity email@example.com -DeliverToMailboxAndForward $true -ForwardingSMTPAddress firstname.lastname@example.org
Example 2: Set forwarding email to External recipient and do not save a copy of the message in the forwarding mailbox
Set-Mailbox -Identity email@example.com -DeliverToMailboxAndForward $false -ForwardingSMTPAddress firstname.lastname@example.org