Add support for providing your own Properties object
bbottema opened this issue · comments
Benny Bottema commented
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).
Benny Bottema commented
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);