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

Test connection without sending email #116

Closed
stevenvanloon opened this issue Nov 14, 2017 · 6 comments
Closed

Test connection without sending email #116

stevenvanloon opened this issue Nov 14, 2017 · 6 comments

Comments

@stevenvanloon
Copy link

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
Copy link
Owner

Not yet, but thanks for reporting. I think it's an interesting feature!

@bbottema bbottema added this to the 5.0.0 milestone Nov 14, 2017
bbottema added a commit that referenced this issue Nov 16, 2017
…ransportStrategy and anynomous / authenticated proxy)
@bbottema
Copy link
Owner

Implemented for version 5.0.0. Should also work with (authenticated) proxy!

@stevenvanloon
Copy link
Author

Looks good!

@bbottema
Copy link
Owner

Released as 5.0.0.rc1-SNAPSHOT. Add OSS' snapshots repo to find it in Maven.

@mrj
Copy link

mrj commented Apr 19, 2019

The docs should say that an error causes a MailException to be thrown.

@bbottema
Copy link
Owner

@mrj Indeed, I will update the documentation and Javadoc to indicate this. Thanks!

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