Test connection without sending email
stevenvanloon opened this issue · 6 comments
stevenvanloon commented
Hi,
At this moment, I test whether a connection to the smtp server is valid or not, by executing this code:
public void testConnection() {
try {
Mailer mailer = createMailer();
Session session = mailer.getSession();
Transport transport = session.getTransport("smtp");
try {
transport.connect();
} finally {
transport.close();
}
} catch (MessagingException e) {
... handle error ...
}
}
That's why I need access to the Session object:
"Providing access to Session instance for emergency fall-back scenario. Please let us know why you need it."
Is there another way to do this without actually sending an email and without using the Session object?
Thanks,
Best regards,
Steven.
bbottema commented
Not yet, but thanks for reporting. I think it's an interesting feature!
bbottema commented
Implemented for version 5.0.0. Should also work with (authenticated) proxy!
stevenvanloon commented
Looks good!
bbottema commented
Released as 5.0.0.rc1-SNAPSHOT. Add OSS' snapshots repo to find it in Maven.
mrj commented
The docs should say that an error causes a MailException to be thrown.