gpt4 book ai didi

java - 使用Java发送电子邮件时如何防止调试代码?

转载 作者:行者123 更新时间:2023-12-01 13:06:10 29 4
gpt4 key购买 nike

我正在使用一个java程序,它将电子邮件发送到指定的地址。该程序运行良好,但它在我的控制台中生成了大量不需要的调试代码。生成调试代码的语句是:

-------
Session session = Session.getInstance(mailProperties, auth);
---
transport = session.getTransport("smtp");
----
transport.sendMessage(message, message.getAllRecipients());

有什么办法可以防止这种情况发生吗?顺便说一句,我使用 mail.jar 和activation.jar 来发送电子邮件。

示例调试代码:

250-SIZE
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-X-ANONYMOUSTLS
250-AUTH NTLM
250-X-EXPS GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250-XEXCH50
250-XRDST
250 XSHADOW
DEBUG SMTP: Found extension "SIZE", arg ""
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 "X-ANONYMOUSTLS", arg ""
DEBUG SMTP: Found extension "AUTH", arg "NTLM"
DEBUG SMTP: Found extension "X-EXPS", arg "GSSAPI NTLM"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: Found extension "XEXCH50", arg ""
DEBUG SMTP: Found extension "XRDST", arg ""
DEBUG SMTP: Found extension "XSHADOW", arg ""
DEBUG SMTP: use8bit false

提前致谢。

最佳答案

来自JavaMail API docs

public void setDebug(boolean debug)

Set the debug setting for this Session.

Since the debug setting can be turned on only after the Session has been created, to turn on debugging in the Session constructor, set the property mail.debug in the Properties object passed in to the constructor to true. The value of the mail.debug property is used to initialize the per-Session debugging flag. Subsequent calls to the setDebug method manipulate the per-Session debugging flag and have no affect on the mail.debug property.

Parameters: debug - Debug setting

关于java - 使用Java发送电子邮件时如何防止调试代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23252140/

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