Forum Discussion
mpeters_all41
Aug 24, 2020Copper Contributor
Failure by sending an email with smtp authentication
Hi Everyone,
actually, I have a problem with sending an email via smtp authenthication. I have already tested it successfully with a Demo Tenant and with my productive tenant, it doesn´t work.
There is a ticket system which must send emails with EXO.
Following my tests:
- create a test account and assign the Office 365 license UserName: smtp-test@test.com
- added the user to each conditional access policy as an execution (the user can log on to the ELT-Tenant without restrictions)
- check the SMTP Auth Settings in the Tenant:
- send a test mail via SMTP with PowerShell (the following website helped https://community.spiceworks.com/how_to/90853-how-to-test-office-365-smtp-server-using-powershell [community.spiceworks.com])
$username = 'smtp-test@test.com' #must be the same like the From parameter in the Send-Mail cmdlet
$recipient = test@test.com' #can be changed
$subject = 'SMTP Auth Test Mail'
$Body = 'This is a test mail via smtp authentication and powershell'
$smtpSrv = 'smtp.office365.com'
$cred = Get-Credential -UserName $username -Message 'please enter your password'
Send-MailMessage –From $username –To $recipient –Subject $subject –Body $Body -SmtpServer $smtpSrv -Credential $cred -UseSsl -Port 587
- Result:
- summary: Basically it works, so I tried it in the productive tenant
Test in the productive tenant:
- create a test account and assign the Office 365 license UserName: smtp-test@productive.onmicrosoft.com
- added the user to each conditional access policy as an execution (the user can log on to the ELT-Tenant without restrictions)
- check the SMTP Auth Settings in the Tenant:
- send a test mail via SMTP with PowerShell
$username = 'smtp-test@productive.onmicrosoft.com' #must be the same like the From parameter in the Send-Mail cmdlet
$recipient = 'test@test.com' #can be changed
$subject = 'SMTP Auth Test Mail'
$Body = 'This is a test mail via smtp authentication and powershell'
$smtpSrv = 'smtp.office365.com'
$cred = Get-Credential -UserName $username -Message 'please enter your password'
Send-MailMessage –From $username –To $recipient –Subject $subject –Body $Body -SmtpServer $smtpSrv -Credential $cred -UseSsl -Port 587
- Result -> not successful
I hope someone can help me, why it works with the demo tenant an not with the productive tenant.
Thanks in advance
Best regards
Marvin Peters
Check also for security defaults: https://docs.microsoft.com/en-us/azure/active-directory/fundamentals/concept-fundamentals-security-defaults
And make sure the account you are using is licensed for ExO.