java mail authen,使用JavaMailSender发送邮件时抛出AuthenticationFailedException

吕华彩
2023-12-01

我正在使用JavaMailSender发送电子邮件,当我使用gmail smtp时似乎一切正常,但当我尝试使用我们的内部smtp邮件服务器时,出现以下错误:

失败

我联系了管理员,他告诉我,由于安全问题,他们不允许在Exchange服务器上进行匿名中继,他问我是否有其他方法可以使用Java发送电子邮件而不使用匿名中继。

更新:

这是我正在使用的配置:

spring.mail.default-encoding=UTF-8

spring.mail.host=smtp.secret.fr

spring.mail.username=secret@secret.com

spring.mail.password=secret

spring.mail.port=587

spring.mail.protocol=smtp

spring.mail.properties.mail.smtp.auth=true

spring.mail.properties.mail.smtp.starttls.enable=true

spring.mail.properties.mail.smtp.starttls.required=true

这是完整堆栈跟踪:

DEBUG: JavaMail version 1.6.2

DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map

DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]

DEBUG SMTP: useEhlo true, useAuth true

DEBUG SMTP: trying to connect to host "smtp.secret.fr", port 587, isSSL false

220 GARM-102R004 Friday, February 1, 2019

DEBUG SMTP: connected to host "smtp.secret.fr", port: 587

EHLO PC100043.secret.fr

250-OVH SMTP PROXY Hello

250-SIZE 104857600

250-ENHANCEDSTATUSCODES

250-AUTH LOGIN PLAIN

250-AUTH=LOGIN PLAIN

250-STARTTLS

250 8BITMIME

DEBUG SMTP: Found extension "SIZE", arg "104857600"

DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""

DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN"

DEBUG SMTP: Found extension "AUTH=LOGIN", arg "PLAIN"

DEBUG SMTP: Found extension "STARTTLS", arg ""

DEBUG SMTP: Found extension "8BITMIME", arg ""

STARTTLS

220 2.0.0 Ready to start TLS

EHLO PC100043.secret.fr

250-OVH SMTP PROXY Hello

250-SIZE 104857600

250-ENHANCEDSTATUSCODES

250-AUTH LOGIN PLAIN

250-AUTH=LOGIN PLAIN

250 8BITMIME

DEBUG SMTP: Found extension "SIZE", arg "104857600"

DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""

DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN"

DEBUG SMTP: Found extension "AUTH=LOGIN", arg "PLAIN"

DEBUG SMTP: Found extension "8BITMIME", arg ""

DEBUG SMTP: protocolConnect login, host=smtp.secret.fr, user=secret@secret.fr, password=

DEBUG SMTP: Attempt to authenticate using mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM XOAUTH2

DEBUG SMTP: Using mechanism LOGIN

DEBUG SMTP: AUTH LOGIN command trace suppressed

DEBUG SMTP: AUTH LOGIN failed

 类似资料: