Failure by sending an email with smtp authentication

%3CLINGO-SUB%20id%3D%22lingo-sub-1607588%22%20slang%3D%22en-US%22%3EFailure%20by%20sending%20an%20email%20with%20smtp%20authentication%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1607588%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Everyone%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eactually%2C%20I%20have%20a%20problem%20with%20sending%20an%20email%20via%20smtp%20authenthication.%26nbsp%3BI%20have%20already%20tested%20it%20successfully%20with%20a%20Demo%20Tenant%20and%20with%20my%20productive%20tenant%2C%20it%20doesn%C2%B4t%20work.%3C%2FP%3E%3CP%3EThere%20is%20a%20ticket%20system%20which%20must%20send%20emails%20with%20EXO.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFollowing%20my%20tests%3A%3C%2FP%3E%3COL%3E%3CLI%3Ecreate%20a%20test%20account%20and%20assign%20the%20Office%20365%20license%20UserName%3A%20smtp-test%40test.com%3C%2FLI%3E%3CLI%3Eadded%20the%20user%20to%20each%20conditional%20access%20policy%20as%20an%20execution%20(the%20user%20can%20log%20on%20to%20the%20ELT-Tenant%20without%20restrictions)%3C%2FLI%3E%3CLI%3Echeck%20the%20SMTP%20Auth%20Settings%20in%20the%20Tenant%3A%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22smtp_settings.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F214290i287B161937CCF7BA%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22smtp_settings.png%22%20alt%3D%22smtp_settings.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%E2%80%83%3C%2FP%3E%3COL%3E%3CLI%3Esend%20a%20test%20mail%20via%20SMTP%20with%20PowerShell%20(the%20following%20website%20helped%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.spiceworks.com%2Fhow_to%2F90853-how-to-test-office-365-smtp-server-using-powershell%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fcommunity.spiceworks.com%2Fhow_to%2F90853-how-to-test-office-365-smtp-server-using-powershell%3C%2FA%3E%20%5Bcommunity.spiceworks.com%5D)%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%24username%20%3D%20'smtp-test%40test.com'%20%23must%20be%20the%20same%20like%20the%20From%20parameter%20in%20the%20Send-Mail%20cmdlet%3C%2FP%3E%3CP%3E%24recipient%20%3D%20test%40test.com'%20%23can%20be%20changed%3C%2FP%3E%3CP%3E%24subject%20%3D%20'SMTP%20Auth%20Test%20Mail'%3C%2FP%3E%3CP%3E%24Body%20%3D%20'This%20is%20a%20test%20mail%20via%20smtp%20authentication%20and%20powershell'%3C%2FP%3E%3CP%3E%24smtpSrv%20%3D%20'smtp.office365.com'%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24cred%20%3D%20Get-Credential%20-UserName%20%24username%20-Message%20'please%20enter%20your%20password'%3C%2FP%3E%3CP%3ESend-MailMessage%20%E2%80%93From%20%24username%20%E2%80%93To%20%24recipient%20%E2%80%93Subject%20%24subject%20%E2%80%93Body%20%24Body%20-SmtpServer%20%24smtpSrv%20-Credential%20%24cred%20-UseSsl%20-Port%20587%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3COL%3E%3CLI%3EResult%3A%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22testmail.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F214291i391479111B586C37%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22testmail.png%22%20alt%3D%22testmail.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%E2%80%83%3C%2FP%3E%3COL%3E%3CLI%3Esummary%3A%20Basically%20it%20works%2C%20so%20I%20tried%20it%20in%20the%20productive%20tenant%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3ETest%20in%20the%20productive%20tenant%3C%2FSTRONG%3E%3A%3C%2FP%3E%3COL%3E%3CLI%3Ecreate%20a%20test%20account%20and%20assign%20the%20Office%20365%20license%20UserName%3A%20%3CA%20href%3D%22mailto%3Asmtp-test%40productive.onmicrosoft.com%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Esmtp-test%40productive.onmicrosoft.com%3C%2FA%3E%3C%2FLI%3E%3CLI%3E%3CSPAN%3Eadded%20the%20user%20to%20each%20conditional%20access%20policy%20as%20an%20execution%20(the%20user%20can%20log%20on%20to%20the%20ELT-Tenant%20without%20restrictions)%3C%2FSPAN%3E%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Restrictions.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F214293iD0A5C6DC4C5C17EA%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22Restrictions.png%22%20alt%3D%22Restrictions.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3COL%3E%3CLI%3Echeck%20the%20SMTP%20Auth%20Settings%20in%20the%20Tenant%3A%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22smtp_settings_prod.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F214294iCD88A398EDEFF8B3%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22smtp_settings_prod.png%22%20alt%3D%22smtp_settings_prod.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3COL%3E%3CLI%3Esend%20a%20test%20mail%20via%20SMTP%20with%20PowerShell%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%24username%20%3D%20'smtp-test%40productive.onmicrosoft.com'%20%23must%20be%20the%20same%20like%20the%20From%20parameter%20in%20the%20Send-Mail%20cmdlet%3C%2FP%3E%3CP%3E%24recipient%20%3D%20'test%40test.com'%20%23can%20be%20changed%3C%2FP%3E%3CP%3E%24subject%20%3D%20'SMTP%20Auth%20Test%20Mail'%3C%2FP%3E%3CP%3E%24Body%20%3D%20'This%20is%20a%20test%20mail%20via%20smtp%20authentication%20and%20powershell'%3C%2FP%3E%3CP%3E%24smtpSrv%20%3D%20'smtp.office365.com'%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24cred%20%3D%20Get-Credential%20-UserName%20%24username%20-Message%20'please%20enter%20your%20password'%3C%2FP%3E%3CP%3ESend-MailMessage%20%E2%80%93From%20%24username%20%E2%80%93To%20%24recipient%20%E2%80%93Subject%20%24subject%20%E2%80%93Body%20%24Body%20-SmtpServer%20%24smtpSrv%20-Credential%20%24cred%20-UseSsl%20-Port%20587%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3COL%3E%3CLI%3EResult%20-%26gt%3B%20not%20successful%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22fehler.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F214295i44C3C1846DCD85F6%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22fehler.png%22%20alt%3D%22fehler.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%E2%80%83%3C%2FP%3E%3CP%3EI%20hope%20someone%20can%20help%20me%2C%20why%20it%20works%20with%20the%20demo%20tenant%20an%20not%20with%20the%20productive%20tenant.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBest%20regards%3C%2FP%3E%3CP%3EMarvin%20Peters%E2%80%83%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1608304%22%20slang%3D%22en-US%22%3ERe%3A%20Failure%20by%20sending%20an%20email%20with%20smtp%20authentication%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1608304%22%20slang%3D%22en-US%22%3E%3CP%3ECheck%20also%20for%20security%20defaults%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Ffundamentals%2Fconcept-fundamentals-security-defaults%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Ffundamentals%2Fconcept-fundamentals-security-defaults%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EAnd%20make%20sure%20the%20account%20you%20are%20using%20is%20licensed%20for%20ExO.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional 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

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.