bbottema/simple-java-mail

batch-module needed for sending mails async

kurtjmeyoung opened this issue ยท 7 comments

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

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.

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 ;-)

Released in 4.7.5

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!

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

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! ๐Ÿ˜„ ๐Ÿ‘

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