How to Change Primary SMTP Address in Microsoft 365

How to Change Primary SMTP Address in Microsoft 365

Admins often struggle to manage the primary SMTP addresses for Microsoft 365 mailboxes, especially in larger organizations, where changing the address for each of them can be challenging. The need to change the primary SMTP address may arise when admins want to move users to another domain, convert user mailbox into a shared mailbox, and more. In such cases, it is essential to change users’ primary SMTP addresses accordingly. This guide will provide detailed steps to change the primary SMTP address to cover all your requirements efficiently.

Change Primary SMTP Address for Microsoft 365 Users

Users’ primary SMTP address, also known as the default email address, can be changed using both Microsoft 365 admin center and Exchange Online PowerShell. Let’s explore how to change the primary SMTP address for Exchange Online mailboxes for various requirements.

  1. Change primary SMTP address for a single Microsoft 365 user
  2. Change primary SMTP address for bulk users using PowerShell
  3. Change user alias address to primary email address for a single user
  4. Change user alias address to primary SMTP address for bulk users
  5. Modify primary SMTP address and username for bulk users
  6. Modify primary SMTP domain for bulk users
  7. Change primary SMTP address for distribution groups
  8. Change primary email address for shared mailboxes

1. Change Default Email Address for a Single Microsoft 365 User

If the user changes their username, admins might want to change the primary SMTP address to match with their username. The primary SMTP address for a user can be changed using either the M365 admin center or PowerShell.

Using Microsoft 365 Admin Center:

  • Navigate to Users –> Active Users in the M365 admin center.
  • Select the desired user and go to the ‘Account’ tab –> Manage username and email.
  • Click on the edit button and modify the primary email address as you wish.
  • Click Done and click on Save changes.

Change Primary SMTP Address - Single user

User Details Panel - Microsoft 365 admin center single user

Using PowerShell:

First, you need to connect to Exchange Online PowerShell.

Case 1: If the mailbox has no alias address (allows to send emails from different email addresses without switching accounts), you can use the below method to change their primary SMTP address. Because this method will remove all the alias addresses of the user.

Set-Mailbox –Identity [email protected] -EmailAddresses “SMTP:[email protected]

The above cmdlet will change the primary SMTP address of the user candy. However, the UserPrincipalName remains unchanged.

Case 2: If you want to retain the users’ alias address and want the current primary SMTP address to be added to the alias address, run the below cmdlet.

Set-Mailbox –Identity [email protected] -WindowsEmailAddress [email protected]

Note: The ‘WindowsEmailAddress’ parameter will work only if the ‘EmailAddressPolicyEnabled’ property is set to ‘False’. Otherwise, the ‘WindowsEmailAddress’ will have no effect on primary SMTP address.

2. Change Primary SMTP Address for Bulk Users Using PowerShell

To change the primary email address for bulk users, you need to proceed with PowerShell, as the admin center doesn’t provide options for bulk users. First, you need to create a CSV file with the user address and new SMTP addresses, as shown below. Please use the column name as same in the image shown below to avoid getting errors while running the script. Otherwise, you can modify the script based on the column name.

SMTP Change for bulk users

Then, run the below script.

$file = Import-Csv <filepath>
Foreach ($UserAddress in $file) 
{ 
Set-Mailbox –Identity $UserAddress.UserAddress -WindowsEmailAddress $UserAddress.NewSMTP)
} 

After running the above script, the primary SMTP address for the users in the CSV file will be changed to the new SMTP address.

3. Change User Alias Address to Default Email Address for a Single User

If admins want to replace the default email address with the previously used email address or any alias address, they can do it using either Microsoft 365 admin center or PowerShell. Remember that if you change the primary SMTP address, the previous one will be automatically added as an alias address. So, you can use it or replace it later if required.

Using Microsoft 365 Admin Center:

  • Navigate to Users –> Active Users in the M365 admin center.
  • Select the desired user and go to the ‘Account’ tab –> Manage username and email.
  • Click on the ellipses available for the desired alias address and select ‘Change to primary email’.
  • Click on Save changes.

Change user alias address to primary address

The alias address will be changed to the primary email address, and the current one will be added as an alias address.

Using PowerShell:

For changing the alias address of a specific user as their default email address, run the below cmdlet. In the ‘-WindowsEmailAddress’ parameter, you can enter the alias address that needs to be changed as the primary SMTP address.

Set-Mailbox –Identity [email protected] -WindowsEmailAddress [email protected] 

Thus, the alias address ‘[email protected]’ will be changed to the primary SMTP address.

4. Change User Alias Address to Primary SMTP Address for Bulk Users

Admins might want to replace users’ primary address with the alias address for multiple users in the organization. In such cases, admins must go with the PowerShell method, as the admin center method is not feasible.

Create a CSV file with two columns denoting users’ UPN and alias addresses that need to be changed to the default email address, as shown below.

change user alias address to primary address for bulk users

Then, run the below script.

$file = Import-Csv <filepath> 
Foreach ($UserAddress in $file) 
{ 
Set-Mailbox –Identity $UserAddress.UserAddress -WindowsEmailAddress $UserAddress.AliasAddress)
} 

The above script modifies the alias address as the primary SMTP address for the user. Their current SMTP address will be added as the alias address.

5. Modify Primary SMTP Address and Username for Bulk Users

As mentioned before, changing the primary SMTP address won’t change the users’ UPN. But Microsoft recommends having users’ UPN match with their primary SMTP address. In such scenarios, admins might want to change the primary SMTP address and username for multiple users. To achieve this,

Create a CSV file with the username and new SMTP address.

Then, run the below script.

$file = Import-Csv <filepath>
Foreach ($UserAddress in $file)
{
Set-Mailbox –Identity $UserAddress.UserAddress -WindowsEmailAddress $UserAddress.NewSMTP -MicrosoftOnlineServicesId $UserAddress.NewSMTP)
}

For Single User: If you want to change the username along with the SMTP address for a specific user, run the format below.

Set-Mailbox –Identity [email protected] -WindowsEmailAddress [email protected] -MicrosoftOnlineServicesId [email protected]

The above format will change both the username and primary SMTP address for the user ‘[email protected]’.

6. Modify Default Email Domain for Bulk Users

Admins might want to move specific users and shared mailboxes from the primary domain to the custom domain or vice versa for various purposes. In such cases, they can achieve this using either the M365 admin center or PowerShell.

Using Microsoft 365 Admin Center:

  • Navigate to Users –> Active Users in the M365 admin center.
  • Select the desired users and click on the ‘Change domains’ option.
  • In the popup, select the domain dropdown and choose the desired domain you wish to change.
  • Click Done and click on Save changes.

Change domain for bulk users admin center

Thus, you can modify the default email domain for bulk mailboxes in Microsoft 365. Though this is an effective approach, you can also achieve this using PowerShell.

Note: If your organization doesn’t contain any custom domains, the ‘Change domain’ option will not be shown.

Using PowerShell:

In the CSV file, you can mention the users’ new domain in the ‘NewSMTP’ field as shown below.

change domain for bulk users powershell

Then, you can run the below script.

$file = Import-Csv <filepath>
Foreach ($UserAddress in $file)
{
Set-Mailbox –Identity $UserAddress.UserAddress -WindowsEmailAddress $UserAddress.NewSMTP)
}

7. Change Primary SMTP Address for Distribution Groups

Admins might want to change the domain of the distribution group or use the same distribution group for various purposes. In such cases, they might need to change the SMTP address accordingly for better collaboration. They can change the primary SMTP address of a distribution group either using Microsoft 365 admin center or PowerShell.

Using Microsoft 365 Admin Center:

  • Navigate to Teams & Groups –> Groups –> Distribution list in the M365 admin center.
  • Click on the desired distribution list and select the ‘Edit’ option available under the ‘Email address’ section in the ‘General’ tab.
  • Then, in the ‘Primary Email Address’ section, select the edit button.
  • Modify the email address and domain as you wish.
  • Click Done and click Save.

change primary SMTP address for distribution list admin center

Change Primary SMTP Address for Distribution Groups Using PowerShell:

Case 1: For changing the primary SMTP address of a single distribution list, you can run the below cmdlet.

Set-DistributionGroup –Identity [email protected] -WindowsEmailAddress [email protected]

The above cmdlet changes the primary SMTP address, as you mentioned in the ‘WindowsEmailAddress’ parameter. The previously used SMTP address will be added as an alias address.

Case 2: For changing the primary email address of multiple distribution groups, follow the steps below.

Create a CSV file with the column names ‘DistributionList’ and ‘NewSMTP’ to denote the distribution group address and the new SMTP address to be changed.

Then, run the below script.

$file = Import-Csv <filepath>
Foreach ($DistributionList in $file)
{
Set-DistributionGroup –Identity $DistributionList.DistributionList -WindowsEmailAddress $DistributionList.NewSMTP)
}

The above script changes the SMTP address for each distribution group included in the CSV file.

8. Change Primary Email Address for Shared Mailboxes

For user offboarding practices, the user mailbox will be converted into a shared mailbox for efficient usage and cost management. In such cases, admins might want to change the shared mailbox primary address based on the purpose of the usage. Changing the primary SMTP address for a shared mailbox can be done either using the admin center or PowerShell.

Using Microsoft 365 Admin Center:

For changing the default email address of a shared mailbox, you can navigate to Teams & Groups –> Shared mailboxes. Then, follow the same procedure mentioned for the user mailbox.

Change Primary SMTP Address for Shared Mailbox Using PowerShell:

For changing the primary SMTP address of a shared mailbox, run the below cmdlet as you did for the user mailbox.

Set-Mailbox –Identity [email protected] -WindowsEmailAddress [email protected] 

The above example changes the primary SMTP address to ‘[email protected]’ and adds the previously used SMTP as an alias address. For changing the primary SMTP address for multiple shared mailboxes, you can follow the same procedure for bulk user mailboxes. Instead of user mailboxes, you can include shared mailbox details in the CSV file.

Get all Microsoft 365 Email Address and Alias Address Using PowerShell

Getting all the email addresses and their alias addresses can be helpful for admins in updating SMTP address with alias address. Also, it helps to verify whether the SMTP address is modified properly, and the previously used addresses were added as alias addresses.

You can use this pre-built script to get all email addresses and alias address in the Microsoft 365 environment. This script support in-built filtering capabilities in which you can drill down data to get only shared mailboxes, distribution groups, etc.

Get all Office 365 email addresses

I hope this blog provides detailed steps to change the primary SMTP address of mailboxes in Microsoft 365, covering prominent use cases efficiently. Drop your queries or requirements in the comments section.

How to Change Primary SMTP Address in Microsoft 365

by Sruthy time to read: 7 min
0