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

batch-module needed for sending mails async #304

Closed
kurtjmeyoung opened this issue Feb 10, 2021 · 7 comments
Closed

batch-module needed for sending mails async #304

kurtjmeyoung opened this issue Feb 10, 2021 · 7 comments

Comments

@kurtjmeyoung
Copy link

Hello,
the documentation states that the batch-module is not required for simply sending mails async, however as soon as I try to send a mail async it states that the batch-module is required. Is this intended? Is the documentation not up to date?

Version of simple-java-mail I'm using is 6.4.4

thanks in advance!
Patrick

@bbottema
Copy link
Owner

Can you share your code please? There'not much I can comment here, except that you shouldn't need the batch-module for simple async sending.

@kurtjmeyoung
Copy link
Author

kurtjmeyoung commented Feb 10, 2021

sure can :-)

I added the library in my SBT project like following:
"org.simplejavamail" % "simple-java-mail" % "6.4.4"

and used it like following:

@Singleton
public class MailService {

    private final Mailer mailService;

    private final Config config;

    @Inject
    public MailService(Config config) {
        this.config = config;
        mailService = MailerBuilder
                .withSMTPServer(config.getString("smtp.host"), config.getInt("smtp.port"))
                .async()
                .buildMailer();
    }

    public void sendTestMail() {
        Email testmail = EmailBuilder.startingBlank()
                .to("Test", "<test-mail-address>")
                .from("TestSender", "<test-sender-address>")
                .withSubject("testmail")
                .withPlainText("hello world")
                .buildEmail();

        mailService.sendMail(testmail);
    }
}

When sending the mail I get following exception:

Execution exception[[ModuleLoaderException: Batch module not found, make sure it is on the classpath (https://github.com/bbottema/simple-java-mail/tree/develop/modules/batch-module)]]

Edit: If I remove ".async()" it works as intended, but not async ;-)

@kurtjmeyoung kurtjmeyoung changed the title batch-module neede for sending mails async batch-module needed for sending mails async Feb 10, 2021
@bbottema bbottema added this to the 6.4.5 milestone Feb 11, 2021
bbottema added a commit that referenced this issue Feb 13, 2021
@bbottema
Copy link
Owner

Released in 4.7.5

@bbottema
Copy link
Owner

So this was a regression bug, or huge oversight on my part, you can say. Surprisingly, this didn't come up before in a bug report, I'm guessing most users just include the batch-module dependency. Thank you for bringing it here!

@kurtjmeyoung
Copy link
Author

thank you very much, for fixing that "issue" that quick!

@matt-snider
Copy link

I just started using this library today and ran into this issue 2 minutes ago. Lucky for me this was fixed just a few hours after I started. Indeed a speedy fix - thank you! 😄 👍

@bbottema
Copy link
Owner

Hah, glad it didn't get a chance to turn you away!

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