我正在使用JavaMailSender发送电子邮件,当我使用gmail smtp时一切正常,但是当我尝试使用内部smtp邮件服务器时出现此错误:
javax.mail.AuthenticationFailedException:535 5.7.1身份验证 失败
一些google搜索后,我在这个线程发现:javax.mail.AuthenticationFailedException: 535 5.7.3 Authentication unsuccessful那我可能不能使用我的电子邮件通过继电器来发送电子邮件。 Exchange服务器的管理员需要授予这样做的权限。
我联系了管理员,他告诉我,由于安全问题,他们不允许在Exchange服务器上进行匿名中继,他问我还有其他方法可以使用Java发送电子邮件而不使用匿名中继。
有人知道任何解决方案吗?
这是我使用的cofiguration:
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=<non-null>
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