Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for providing your own Properties object #61

Closed
bbottema opened this issue Jan 27, 2017 · 1 comment
Closed

Add support for providing your own Properties object #61

bbottema opened this issue Jan 27, 2017 · 1 comment
Milestone

Comments

@bbottema
Copy link
Owner

bbottema commented Jan 27, 2017

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).

bbottema referenced this issue Jan 27, 2017
…ties object (with either String values or proper Object values)
@bbottema bbottema added this to the 4.1.3 milestone Jan 28, 2017
@bbottema
Copy link
Owner Author

bbottema commented Jan 28, 2017

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant