Skip to content

Commit 503e458

Browse files
committed
fix #7
1 parent 5b4d4cc commit 503e458

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/main/java/org/codemonkey/simplejavamail/Mailer.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,17 @@ public final void sendMail(final Email email)
255255
* Simply logs host details, credentials used and whether authentication will take place and finally the transport protocol used.
256256
*/
257257
private void logSession(Session session, TransportStrategy transportStrategy) {
258-
final String logmsg = "starting mail session (host: %s, port: %s, username: %s, authenticate: %s, transport: %s)";
259258
Properties properties = session.getProperties();
260-
logger.debug(String.format(logmsg, properties.get(transportStrategy.propertyNameHost()),
261-
properties.get(transportStrategy.propertyNamePort()), properties.get(transportStrategy.propertyNameUsername()),
262-
properties.get(transportStrategy.propertyNameAuthenticate()), transportStrategy));
259+
final String specifics;
260+
if (transportStrategy != null) {
261+
final String logmsg = "starting mail session (host: %s, port: %s, username: %s, authenticate: %s, transport: %s)";
262+
specifics = String.format(logmsg, properties.get(transportStrategy.propertyNameHost()),
263+
properties.get(transportStrategy.propertyNamePort()), properties.get(transportStrategy.propertyNameUsername()),
264+
properties.get(transportStrategy.propertyNameAuthenticate()), transportStrategy);
265+
} else {
266+
specifics = properties.toString();
267+
}
268+
logger.debug(String.format("starting mail session (%s)", specifics));
263269
}
264270

265271
/**

0 commit comments

Comments
 (0)