gpt4 book ai didi

java - Log4j2 SMTP 到 Office365

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:57:13 24 4
gpt4 key购买 nike

我正在尝试使用 Log4j2 通过邮件发送我的错误日志。但是我在连接到 office365 时遇到问题。

我的配置是这样的:

<SMTP name="Mail" subject="Worker Error" to="recipient@domain.com" from="error@domain.com"
smtpHost="smtp.office365.com" smtpPort="587" smtpUsername="error@domain.com" smtpPassword="mypassword"
smtpProtocol="smtp" bufferSize="512" smtpDebug="true">
</SMTP>

这是我得到的错误。

EHLO 192.168.1.106
250-VI1PR02CA0004.outlook.office365.com Hello [80.110.25.16]
250-SIZE 157286400
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250 CHUNKING
DEBUG SMTP: Found extension "SIZE", arg "157286400"
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: use8bit false
MAIL FROM:<error@domain.com>
530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM
DEBUG SMTP: got response code 530, with response: 530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM

我尝试将协议(protocol)更改为 smtps,因为我认为它可能需要 TLS,但它甚至无法连接。

DEBUG SMTP: trying to connect to host "smtp.office365.com", port 587, isSSL true
2015-10-20 10:51:24,625 main ERROR Error occurred while sending e-mail notification. javax.mail.MessagingException: Could not connect to SMTP host: smtp.office365.com, port: 587;
nested exception is:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

有什么想法吗?

最佳答案

坚持使用 smtp,并将其添加到您的初始化代码中:

import java.util.Properties;
...
Properties p = System.getProperties();
p.setProperty("mail.smtp.starttls.enable", "true");

关于java - Log4j2 SMTP 到 Office365,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33232517/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com