Skip to content

Commit

Permalink
0002814: Add debug logging for SMTP session
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Sep 20, 2016
1 parent 34d1bff commit 5bfb76a
Showing 1 changed file with 12 additions and 0 deletions.
Expand Up @@ -20,6 +20,8 @@
*/
package org.jumpmind.symmetric.service.impl;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.Date;
import java.util.Properties;

Expand Down Expand Up @@ -70,6 +72,13 @@ public String sendEmail(String subject, String text, String recipients, TypedPro
protected String sendEmail(String subject, String text, String recipients, Properties prop,
String transportType, boolean useAuth, String user, String password) {
Session session = Session.getInstance(prop);
ByteArrayOutputStream ba = null;
if (log.isDebugEnabled()) {
session.setDebug(true);
ba = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(ba);
session.setDebugOut(ps);
}
Transport transport;
try {
transport = session.getTransport(transportType);
Expand Down Expand Up @@ -110,6 +119,9 @@ protected String sendEmail(String subject, String text, String recipients, Prope
} catch (MessagingException e) {
}
}
if (log.isDebugEnabled()) {
log.debug(ba.toString());
}
return null;
}

Expand Down

0 comments on commit 5bfb76a

Please sign in to comment.