Forum Discussion

mpeters_all41's avatar
mpeters_all41
Copper Contributor
Aug 24, 2020

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:

  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:

  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:

 

  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)

 

  1. check the SMTP Auth Settings in the Tenant:

 

  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

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 

Resources