# # 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 = 'test@test.com' # 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