How to inactive user mail in sharepoint

In SharePoint, you can inactive a user's mail account by following these steps:

Method 1: Using SharePoint Central Administration

  1. Go to SharePoint Central Administration > Application Management > Service Applications > Email Service.
  2. Click on the "Manage Email Accounts" button.
  3. Find the user's email account in the list and click on the "Edit" button.
  4. In the "Edit Email Account" page, scroll down to the "Account Status" section.
  5. Select "Inactive" from the dropdown menu.
  6. Click "OK" to save the changes.

Method 2: Using PowerShell

You can use PowerShell to inactive a user's mail account in SharePoint. Here's an example script:

$site = Get-SPSite -Identity <site_url>
$emailService = $site.EmailService
$emailAccount = $emailService.GetEmailAccount(<user_email>)
$emailAccount.AccountStatus = [Microsoft.SharePoint.Administration.Email.EmailAccountStatus]::Inactive
$emailAccount.Update()

Replace <site_url> with the URL of your SharePoint site, and <user_email> with the email address of the user you want to inactive.

Method 3: Using SharePoint Online Management Shell

If you're using SharePoint Online, you can use the SharePoint Online Management Shell to inactive a user's mail account. Here's an example script:

Connect-SPOService -Url <tenant_url>
Get-SPOEmailAccount -Identity <user_email> | Set-SPOEmailAccount -AccountStatus Inactive

Replace <tenant_url> with the URL of your SharePoint Online tenant, and <user_email> with the email address of the user you want to inactive.

Note: Before inactivating a user's mail account, make sure you have the necessary permissions and that the user's email account is not being used by any other services or applications.