diff --git a/src/main/java/org/codemonkey/simplejavamail/Mailer.java b/src/main/java/org/codemonkey/simplejavamail/Mailer.java index dd25679f9..1904ca6a3 100644 --- a/src/main/java/org/codemonkey/simplejavamail/Mailer.java +++ b/src/main/java/org/codemonkey/simplejavamail/Mailer.java @@ -157,7 +157,7 @@ public Mailer(final String host, final Integer port, final String username, fina * @see TransportStrategy#propertyNameUsername() * @see TransportStrategy#propertyNameAuthenticate() */ - public Session createMailSession(final String host, final Integer port, final String username, final String password) { + protected Session createMailSession(final String host, final Integer port, final String username, final String password) { if (transportStrategy == null) { logger.warn("Transport Strategy not set, using plain SMTP strategy instead!"); transportStrategy = TransportStrategy.SMTP_PLAIN; @@ -200,15 +200,34 @@ public Mailer(final String host, final Integer port, final String username, fina this(host, port, username, password, TransportStrategy.SMTP_PLAIN); } + /** + * In case Simple Java Mail falls short somehow, you can get a hold of the internal {@link Session} instance to debug or tweak. Please + * let us know why you are needing this on https://github.com/bbottema/simple-java-mail/issues. + */ + public Session getSession() { + logger.warn("Providing access to Session instance for emergency fall-back scenario. Please let us know why you need it."); + logger.warn("\t>https://github.com/bbottema/simple-java-mail/issues"); + return session; + } + /** * Actually sets {@link Session#setDebug(boolean)} so that it generates debug information. * * @param debug Flag to indicate debug mode yes/no. */ - public void setDebug(boolean debug) { + public void setDebug(final boolean debug) { session.setDebug(debug); } + /** + * Copies all property entries into the {@link Session} using {@link Session#getProperties()}. + * + * @param properties The source properties to add or override in the internal {@link Session} instance. + */ + public void applyProperties(final Properties properties) { + session.getProperties().putAll(properties); + } + /** * Processes an {@link Email} instance into a completely configured {@link Message}. *