Skip to content

Test connection without sending email #116

@stevenvanloon

Description

@stevenvanloon

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions