nithril / smtp-connection-pool

SMTP Connection Pool
Apache License 2.0
47 stars 19 forks source link

Access to mail Session #1

Closed brunorene closed 9 years ago

brunorene commented 9 years ago

Hi,

When you create a SmtpConnectionFactoryBuilder you can create a inner Session that is not accessible from the outside. So when you want to create a new MimeMessage you can't reuse the Session created inside the Builder. I had to create a SmtpConnectionFactory directly and create the Session outside it in order to create new MimeMessages

Regards

nithril commented 9 years ago

Hi!

The session is available through SmtpConnectionFactory#getSession. In my opinion it is more logical to access it using this method than through the builder that is not a reusable component

nithril commented 9 years ago

I have added ClosableSmtpConnection#getSession and SmtpConnectionPool#getSession

You will be able to do:

try (ClosableSmtpConnection transport = smtpConnectionPool.borrowObject()) {
    MimeMessage mimeMessage = new MimeMessage(transport.getSession());
    [...]
}