Skip to content

Test connection without sending email #116

Closed

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.

Activity

  1. bbottema commented on Nov 14, 2017

    @bbottema
    Owner

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

  2. added this to the 5.0.0 milestone on Nov 14, 2017
  3. added a commit that references this issue on Nov 16, 2017
  4. bbottema commented on Nov 16, 2017

    @bbottema
    Owner

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

  5. added a commit that references this issue on Nov 16, 2017
  6. stevenvanloon commented on Nov 17, 2017

    @stevenvanloon
    Author

    Looks good!

  7. bbottema commented on Dec 26, 2017

    @bbottema
    Owner

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

  8. mrj commented on Apr 19, 2019

    @mrj

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

  9. bbottema commented on Apr 19, 2019

    @bbottema
    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions