Failure by sending an email with smtp authentication

Highlighted
New Contributor

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:

  1. create a test account and assign the Office 365 license UserName: smtp-test@test.com
  2. added the user to each conditional access policy as an execution (the user can log on to the ELT-Tenant without restrictions)
  3. check the SMTP Auth Settings in the Tenant:

smtp_settings.png

  1. 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

 

  1. Result:

testmail.png

 

  1. summary: Basically it works, so I tried it in the productive tenant

 

Test in the productive tenant:

  1. create a test account and assign the Office 365 license UserName: smtp-test@productive.onmicrosoft.com
  2. added the user to each conditional access policy as an execution (the user can log on to the ELT-Tenant without restrictions)

Restrictions.png

 

  1. check the SMTP Auth Settings in the Tenant:

smtp_settings_prod.png

 

  1. 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

 

  1. Result -> not successful

fehler.png

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 

1 Reply
Highlighted

Check also for security defaults: https://docs.microsoft.com/en-us/azure/active-directory/fundamentals/concept-fundamentals-security-d...

And make sure the account you are using is licensed for ExO.