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

reusing jakarta.mail.Transport for multiple without using batch-module #569

Open
rw7 opened this issue Jan 8, 2025 · 0 comments
Open

reusing jakarta.mail.Transport for multiple without using batch-module #569

rw7 opened this issue Jan 8, 2025 · 0 comments

Comments

@rw7
Copy link

rw7 commented Jan 8, 2025

I'd like to reuse a SMTP connection (and therefore jakarta.mail.Transport) for sending more that one email. I'd like to have some API that can be used like this:

try(MailerTransport transport = mailer.openTransport())
{
	for(int i = 0; i<5; i++)
	{
		transport.sendMail(EmailBuilder.startingBlank().
				...
				withSubject("mail " + i + "/5"));
	}
}

I can't use batch-module, as it wants to maintain threads and the message queue for me. I have just one thread fetching emails from the database and sending it to smtp blockingly. No need for parallel threads or connections pools. Just one thread reusing the transport for more than one email.

I made this possible with hacking simple-java-mail, but it says: "Providing access to Session instance for emergency fall-back scenario. Please let us know why you need it." So here I am.

Best regards,
Ralf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant