Java provides battle-tested mail sending capabilities with the package. Using this library we can connect to SMTP mailboxes and send emails using the SMTP transport. To send emails from MailSlurp accounts we can use the MailSlurp Java library to create an inbox and get the username, password, port and host for SMTP access.

See the JavaDocs documentation for more information.

Install maven dependencies

First let us install MailSlurp and the Java mail package using Maven.

Setup mailbox access

Next we can create a new throw-away email inbox using MailSlurp. First we must set the API Key for the MailSlurp client.

Send email with SMTP mail transport

To send an email using Javax Mail package first create an inbox then get the inbox access details from MailSlurp. Use the returned imap smtp access details to configure the mail properties.

More options

For more email options with Java see the MailSlurp Java documentation and the examples repositories.