我正在使用我的 Spring Boot 服务器发送电子邮件
我正在使用 org.springframework.boot:spring-boot-starter-mail:3.3.1
但是我得到了大量的日志输出。有什么办法可以禁用它吗? 据我所知,日志被打印到 Stdio
示例日志
250 OK
DEBUG SMTP: message successfully delivered to mail server
QUIT
221 /127.0.0.1 Service closing transmission channel
DEBUG: getProvider() returning jakarta.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "localhost", port 3025, isSSL false
220 /127.0.0.1 GreenMail SMTP Service v2.0.1 ready
DEBUG SMTP: connected to host "localhost", port: 3025
EHLO swp73
250-/127.0.0.1
250 AUTH PLAIN LOGIN
DEBUG SMTP: Found extension "AUTH", arg "PLAIN LOGIN"
DEBUG SMTP: protocolConnect login, host=localhost, [email protected], 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 succeeded
DEBUG SMTP: use8bit false
MAIL FROM:<[email protected]>
250 OK
RCPT TO:<[email protected]>
250 OK
DEBUG SMTP: Verified Addresses
DEBUG SMTP: [email protected]
DATA
354 Start mail input; end with <CRLF>.<CRLF>
Date: Fri, 19 Jul 2024 14:58:41 +0200 (CEST)
From: [email protected]
To: [email protected]
Message-ID: <1919633455.3.1721393921703@swp73>
Subject: Verify Email
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
消息会话属性上的“mail.debug”属性应为“false”,如下所示:
Properties properties = new Properties();
properties.put("mail.debug", "false");
Session session = Session.getInstance(properties);
Message msg = new MimeMessage(session);