|
|
@@ -25,6 +25,7 @@ import javax.mail.util.ByteArrayDataSource;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
+import java.io.PrintStream;
|
|
|
import java.nio.charset.Charset;
|
|
|
import java.util.Date;
|
|
|
|
|
|
@@ -78,6 +79,11 @@ public class Mail {
|
|
|
private boolean useGlobalSession = false;
|
|
|
|
|
|
/**
|
|
|
+ * debug输出位置,可以自定义debug日志
|
|
|
+ */
|
|
|
+ private PrintStream debugOutput;
|
|
|
+
|
|
|
+ /**
|
|
|
* 创建邮件客户端
|
|
|
*
|
|
|
* @param mailAccount 邮件帐号
|
|
|
@@ -345,6 +351,18 @@ public class Mail {
|
|
|
this.useGlobalSession = isUseGlobalSession;
|
|
|
return this;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置debug输出位置,可以自定义debug日志
|
|
|
+ *
|
|
|
+ * @param debugOutput debug输出位置
|
|
|
+ * @return this
|
|
|
+ * @since 5.5.6
|
|
|
+ */
|
|
|
+ public Mail setDebugOutput(PrintStream debugOutput) {
|
|
|
+ this.debugOutput = debugOutput;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
// --------------------------------------------------------------- Getters and Setters end
|
|
|
|
|
|
/**
|
|
|
@@ -453,8 +471,14 @@ public class Mail {
|
|
|
authenticator = new UserPassAuthenticator(mailAccount.getUser(), mailAccount.getPass());
|
|
|
}
|
|
|
|
|
|
- return isSingleton ? Session.getDefaultInstance(mailAccount.getSmtpProps(), authenticator) //
|
|
|
+ final Session session = isSingleton ? Session.getDefaultInstance(mailAccount.getSmtpProps(), authenticator) //
|
|
|
: Session.getInstance(mailAccount.getSmtpProps(), authenticator);
|
|
|
+
|
|
|
+ if(null != this.debugOutput){
|
|
|
+ session.setDebugOut(debugOutput);
|
|
|
+ }
|
|
|
+
|
|
|
+ return session;
|
|
|
}
|
|
|
// --------------------------------------------------------------- Private method end
|
|
|
}
|