Created
July 8, 2020 17:52
-
-
Save ThabetAmer/8dda6a748b88a4c35e12c6884e867400 to your computer and use it in GitHub Desktop.
Enables SMTP Auth for Office365 emails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Enables SMTP Auth for Office365 emails, so you can send emails via a script for application. | |
# Shall be run via Powershell terminal. | |
# | |
# Define your email address that will send emails via SMTP auth | |
$emailAddress = '[email protected]' | |
# asks for email/password | |
$UserCredential = Get-Credential | |
# creates basic auth session | |
$Session = New-PSSession -ConfigurationName Microsoft.Exchange \ | |
-ConnectionUri https://outlook.office365.com/powershell-liveid/ | |
-Credential $UserCredential -Authentication Basic -AllowRedirection | |
# initiates the session | |
Import-PSSession $Session -DisableNameChecking | |
# enables SMTP auth | |
Set-CASMailbox -Identity $emailAddress -SmtpClientAuthenticationDisabled $false | |
# verifies the action, shall be set as False | |
Get-CASMailbox -Identity $emailAddress | Format-List SmtpClientAuthenticationDisabled |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment