skip to Main Content

Target mailbox doesn’t have an SMTP proxy matching

You are migrating mailboxes from Exchange on-premises to Exchange Online in Office 365. This time an error is showing that the mailbox status failed. The target mailbox doesn’t have an SMTP proxy matching ‘<domain>.mail.onmicrosoft.com’. Why is it happening, and what is the solution to it? In this article, you will learn how to solve the status failed when migrating mailbox to Exchange Online.

Solution to target mailbox doesn’t have an SMTP proxy matching

This issue may occur if one of the following conditions is true:

  • The source mailbox isn’t stamped to have a <domain>.mail.onmicrosoft.com SMTP address.
  • The proxy address <domain>.mail.onmicrosoft.com is not synced to Office 365 on the corresponding cloud mail-user object.

It’s important to add the proxy address <domain>.mail.onmicrosoft.com to the mailboxes. If you don’t do that, you can’t proceed further. The mailbox migration will fail. The fastest way to solve this is to bulk add the <domain>.mail.onmicrosoft.com to all the mailboxes.

Get list mailboxes without <domain>.mail.onmicrosoft.com SMTP address

Run Exchange Management Shell as administrator and connect to the on-premises Exchange Server. List all the mailboxes with the missing <domain>.mail.onmicrosoft.com SMTP address.

In my example, <domain>.mail.onmicrosoft.com is the exoip.mail.onmicrosoft.com address. Change exoip to the name of your tenant.

[PS] C:\>Get-Mailbox -ResultSize Unlimited -Filter {EmailAddresses -NotLike "*@exoip.mail.onmicrosoft.com"} | Select-Object UserPrincipalName,Alias

UserPrincipalName           Alias
-----------------           -----
Amanda.Morgan@exoip.com     Amanda.Morgan
Anna.Welch@exoip.com        Anna.Welch
Benetiz.Anees@exoip.com     Benetiz.Anees
Boris.Campbell@exoip.com    Boris.Campbell
Carl.Kelly@exoip.com        Carl.Kelly
Christopher.Payne@exoip.com Christopher.Payne

Get list mailboxes with <domain>.mail.onmicrosoft.com SMTP address

Do you like to have a list with all the mailboxes that have the <domain>.mail.onmicrosoft SMTP address? Change -NotLike to -Like and run the cmdlet.

[PS] C:\>Get-Mailbox -ResultSize Unlimited -Filter {EmailAddresses -Like "*@exoip.mail.onmicrosoft.com"} | Select-Object UserPrincipalName,Alias

UserPrincipalName        Alias
-----------------        -----
Kyle.Peake@exoip.com     Kyle.Peake
Kylie.Davidson@exoip.com Kylie.Davidson
Larson.Tevin@exoip.com   Larson.Tevin
Madeleine.Ross@exoip.com Madeleine.Ross

We know why the error target mailbox doesn’t have an SMTP proxy matching is showing. We listed which mailboxes are missing the SMTP address. In the next step, we are going to bulk add the missing SMTP address to the mailboxes.

Bulk add <domain>.mail.onmicrosoft.com SMTP address with PowerShell

We have two options to set the <domain>.mail.onmicrosoft.com SMTP address to all the mailboxes.

Option 1: Bulk add <domain>.mail.onmicrosoft.com SMTP with two PowerShell cmdlets

Run the following two cmdlets to set the alias@domain.mail.onmicrosoft.com as a secondary SMTP address.

[PS] C:\>$NoSMTP = Get-Mailbox -ResultSize Unlimited | Where-Object {($_.EmailAddresses -NotLike "*@exoip.mail.onmicrosoft.com")}

[PS] C:\>$NoSMTP | ForEach {Set-Mailbox -Identity $_.UserPrincipalName -EmailAddresses @{add=$_.Alias+"@exoip.mail.onmicrosoft.com"}}

Option 2: Bulk add <domain>.mail.onmicrosoft.com SMTP with PowerShell script

Create two folders with the name scripts and temp in the C: drive. Download the PowerShell script Add-onmicrosoft-SMTP.ps1 and place it in C:\scripts folder. You can copy the below code and paste it in Notepad. Save the file as Add-onmicrosoft-SMTP.ps1 in the C:\scripts folder. After running the script, the output will be logged to the temp folder with the file name Add-onmicrosoft-SMTP.log.

# Output will be added to C:\temp folder. Open the Add-onmicrosoft-SMTP.log with a text editor. For example, Notepad.
Start-Transcript -Path C:\temp\Add-onmicrosoft-SMTP.log -Append

# Get all mailboxes
$Mailboxes = Get-Mailbox -ResultSize Unlimited

# Loop through each mailbox
foreach ($Mailbox in $Mailboxes) {

    # Search for @mail.onmicrosoft.com SMTP in every mailbox
    $OnMicrosoftAddress = $Mailbox.EmailAddresses | Where-Object { $_.AddressString -like "*@mail.onmicrosoft.com" }
      
    # Do nothing when there is already an @mail.onmicrosoft.com SMTP configured
    If (($OnMicrosoftAddress | Measure-Object).Count -eq 0) {

        # Change exoip with the domain name that you want to add as SMTP
        $OnMSAddress = "$($Mailbox.Alias)@exoip.mail.onmicrosoft.com"
        Set-Mailbox $Mailbox -EmailAddresses @{add = $OnMSAddress }

        # Write output
        Write-Host "Adding $($OnMSAddress) to $($Mailbox.Name) Mailbox" -ForegroundColor Green
    }
}

Stop-Transcript

Let’s see the PowerShell script in action. Run Exchange Management Shell as administrator. Change the directory to the scripts folder and run the script. The PowerShell script will go through the Exchange On-premises mailboxes and add the <domain>.mail.onmicrosoft.com to every mailbox as a secondary SMTP address.

[PS] C:\>cd \scripts
[PS] C:\scripts>.\Add-onmicrosoft-SMTP.ps1
Transcript started, output file is C:\temp\Add-onmicrosoft-SMTP.log
Adding Amanda.Morgan@exoip.mail.onmicrosoft.com to Amanda Morgan Mailbox
Adding Anna.Welch@exoip.mail.onmicrosoft.com to Anna Welch Mailbox
Adding Benetiz.Anees@exoip.mail.onmicrosoft.com to Benetiz Anees Mailbox
Adding Boris.Campbell@exoip.mail.onmicrosoft.com to Boris Campbell Mailbox
Adding Carl.Kelly@exoip.mail.onmicrosoft.com to Carl.Kelly Mailbox
Adding Christopher.Payne@exoip.mail.onmicrosoft.com to Christopher Payne Mailbox
Transcript stopped, output file is C:\temp\Add-onmicrosoft-SMTP.log

The last step is to verify the results and to make sure that we will not see the error target mailbox doesn’t have an SMTP proxy matching when migration mailboxes to Exchange Online.

Verify the results

If you used option 2 to set the <domain>.mail.onmicrosoft.com SMTP with the PowerShell script, check the log file. Go to the C:\temp folder and open the file Add-onmicrosoft-SMTP.log with the application Notepad.

Target mailbox doesnt have an SMTP proxy matching log

Run the cmdlet to check if there are mailboxes configured without the SMTP <domain>.mail.onmicrosoft.com. The output is empty after running the cmdlet. That’s because all the mailboxes are configured with the <domain>.mail.onmicrosoft.com.

[PS] C:\>Get-Mailbox -ResultSize Unlimited -Filter {EmailAddresses -NotLike "*@exoip.mail.onmicrosoft.com"}

Did it help you to solve the error target mailbox doesn’t have an SMTP proxy matching?

Read more: Complete migration batch with PowerShell »

Conclusion

In this article, you learned why the error target mailbox doesn’t have an SMTP proxy matching is showing. Add the <domain>.mail.onmicrosoft.com SMTP to the mailboxes with the PowerShell cmdlets showing in this article. After setting the SMTP address, run Azure AD Connect to sync the on-premises environment with the cloud. Move the mailbox to Exchange Online and have a look at the move request. This time the error is not showing anymore.

Did you enjoy this article? You may also like Get move request batch in Exchange Online. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 3 Comments

  1. Hi Ali!
    I have the following problem: the mailbox was migrated to EXO but for some unknown reason, the Exchange Online mailbox does not have the secondary SMTP address .mail.onmicrosoft.com. However, looking at the Exchange On-Prem MEU object, that address exists as a secondary SMTP address. And it is also configured as Remote Routing Address. Apparently the Azure AD Connect server is not syncing the change to Azure AD but I do not see any error. I would appreciate any help from you! Thank you!

  2. i have added the SMTP proxy matching ‘.mail.onmicrosoft.com but when i go to migrate the mailbox it still gives me the error message saying

    “The target mailbox doesn’t have an SMTP proxy matching “domain.mail.onmicrosoft.com’.

    How can i fix this?

Leave a Reply

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

Back To Top