bbottema / simple-java-mail

Simple API, Complex Emails (Jakarta Mail smtp wrapper)

Home Page:http://www.simplejavamail.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for providing your own Properties object

bbottema opened this issue · comments

Simple Java Mail currently supports loading config properties either directly from file or else from an InputStream.

It should also be possible to trigger this configure procedure with a provided Properties source for more flexibility.

Not only allows this for more flexibility, you can now provide non-String values which are used as-is, rather than parsed to types appropriate for Simple Java Mail (booleans, ints ad TransportStrategy etc).

Released in 4.1.3.

You can now do something like this:

Properties source = new Properties();
source.put("simplejavamail.javaxmail.debug", "true");
source.put("simplejavamail.transportstrategy", "SMTP_SSL");
source.put("simplejavamail.smtp.host", "smtp.default.com");
source.put("simplejavamail.smtp.port", "25");
source.put("simplejavamail.smtp.username", "username");
source.put("simplejavamail.smtp.password", "password");

ConfigLoader.loadProperties(source, addOrReplaceProperties);

You can even skip the String interpretation and provide your own converted value objects:

Properties source = new Properties();
source.put("simplejavamail.javaxmail.debug", true);
source.put("simplejavamail.transportstrategy", TransportStrategy.SMTP_SSL);
source.put("simplejavamail.smtp.host", "smtp.default.com");
source.put("simplejavamail.smtp.port", 25);
source.put("simplejavamail.smtp.username", "username");
source.put("simplejavamail.smtp.password", "password");

ConfigLoader.loadProperties(source, addOrReplaceProperties);