Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11601

Azure SMTP authentication failed

$
0
0

I have followed the steps at Quickstart: How to create authentication credentials for sending emails using SMTP

  • created a service called "outgoing-mail"
  • registered an app
  • created a role with scope to above service and permissions
    • Microsoft.Communication/CommunicationServices/Read
    • Microsoft.Communication/EmailServices/write
    • (gave it the rest of Microsoft.Communication to be sure)
  • assigned the role to the app
  • created a client secret
  • concatenated the username

I try to send an e-mail but the authentication does not work. I tried:

  • different clients => no difference
  • setting mail.smtp.auth.mechanisms => default of LOGIN seems correct, the others return not supported

Code:

package com.zenmoimport jakarta.mail.Authenticatorimport jakarta.mail.PasswordAuthenticationimport jakarta.mail.*import java.util.*fun main() {    val prop: Properties = Properties()    prop.put("mail.smtp.auth", true)    prop.put("mail.smtp.starttls.enable", "true")    prop.put("mail.smtp.host", "smtp.azurecomm.net")    prop.put("mail.smtp.port", "587")    prop.put("mail.smtp.ssl.trust", "smtp.azurecomm.net")    val session = Session.getInstance(prop, object : Authenticator() {        override fun getPasswordAuthentication() = PasswordAuthentication("outgoing-mail.c8d8ffe4-1ff2-4b5b-a6e5-391eac5e1238.1d9c9a28-bfa5-49e1-b0b5-08e4041f77b1","R4S***************************"        )    })    session.debug = true    val smtpTransport = session.getTransport("smtp")    smtpTransport.connect()    smtpTransport.close()}

debug output:

DEBUG: setDebug: Jakarta Mail version 2.1.1DEBUG: getProvider() returning jakarta.mail.Provider[TRANSPORT,smtp,org.eclipse.angus.mail.smtp.SMTPTransport,Oracle]DEBUG SMTP: need username and password for authenticationDEBUG SMTP: protocolConnect returning false, host=smtp.azurecomm.net, user=erik, password=<null>DEBUG SMTP: useEhlo true, useAuth trueDEBUG SMTP: trying to connect to host "smtp.azurecomm.net", port 587, isSSL false220 ic3-transport-smtp-acs-deployment-54b7c4d9cd-m6ghd Microsoft ESMTP MAIL Service ready at Fri, 26 Jan 2024 15:15:55 +0000 (08DBFCDFC373B98E)DEBUG SMTP: connected to host "smtp.azurecomm.net", port: 587EHLO legion5pro250-ic3-transport-smtp-acs-deployment-54b7c4d9cd-m6ghd Hello [89.255.15.206]250-SIZE 10485760250 STARTTLSDEBUG SMTP: Found extension "SIZE", arg "10485760"DEBUG SMTP: Found extension "STARTTLS", arg ""STARTTLS220 2.0.0 SMTP server readyEHLO legion5pro250-ic3-transport-smtp-acs-deployment-54b7c4d9cd-m6ghd Hello [89.255.15.206]250-SIZE 10485760250 AUTH LOGINDEBUG SMTP: Found extension "SIZE", arg "10485760"DEBUG SMTP: Found extension "AUTH", arg "LOGIN"DEBUG SMTP: protocolConnect login, host=smtp.azurecomm.net, user=outgoing-mail.c8d8ffe4-1ff2-4b5b-a6e5-391eac5e1238.1d9c9a28-bfa5-49e1-b0b5-08e4041f77b1, password=<non-null>DEBUG SMTP: Attempt to authenticate using mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM XOAUTH2 DEBUG SMTP: Using mechanism LOGINDEBUG SMTP: AUTH LOGIN command trace suppressedDEBUG SMTP: AUTH LOGIN failed

Viewing all articles
Browse latest Browse all 11601

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>