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 access to the underlying javax.mail.Session properties #19

Closed
nclemeur opened this issue Jul 21, 2015 · 4 comments
Closed

Add access to the underlying javax.mail.Session properties #19

nclemeur opened this issue Jul 21, 2015 · 4 comments
Assignees
Milestone

Comments

@nclemeur
Copy link

I had a case where the connection to the smtp server was hanging and never returning. It seems to be linked to the fact no value for the timeout parameters was is given when building the session. The parameters are mail.smtp.timeout and mail.smtp.connectiontimeout and there is currently no easy way to set these.

One option is to use the Mailer constructor with the Session argument, but then it fails on a NPE in logSession because the transportStrategy is not set. Also, a lot of the setup work has to be redone using this approach.

I think a better approach, would be to provide another arguments to the Mailer constructor, adding a Properties argument which would allow for full customisation of the session properties.

@bbottema
Copy link
Owner

I agree. Furthermore, as a fallback scenario I'm going to provide access to the internal Session object.

@bbottema bbottema self-assigned this Jul 21, 2015
@bbottema bbottema added this to the v2.2 milestone Jul 21, 2015
bbottema added a commit that referenced this issue Jul 21, 2015
@bbottema
Copy link
Owner

I've added applyProperties(Properties) and getSession() to Mailer's API.

Released in 2.3

@stink0r
Copy link

stink0r commented Mar 13, 2018

code tells me to let you guys know why we are using "getSession()" - I am using it since the configuration of TLS access on port 587 is far more than easy. You guys are doing a perfect job where I am confident to re-use it at any place in my application, especially with the log4j-SMTPAppender.

Code I use:
return MailerBuilder.withSMTPServer(getSMTPHost(), TLS_PORT, getSMTPUsername(), getSMTPPassword())
.withTransportStrategy(TransportStrategy.SMTP_TLS)
.buildMailer()
.getSession();

@bbottema
Copy link
Owner

Thanks @sYbb12, that's great to hear!

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

3 participants