Is it possible to send email without JDK?

106 views Asked by At

I'm aware about JDK implementation of email sending (via SMTP), but I'm looking for something custom, which would not use JDK. Such libraries exist? I need it for better testability of my app.

2

There are 2 answers

7
cherouvim On BEST ANSWER

Maybe use apache commons exec to run something like:

echo "hello" | mail -s subject [email protected]
0
Hannes On

I need it for better testability of my app.

Use the mail functionality from java-mail. That's how it's done.

For you testcases use a Dummy-Implementation using a singleton, or just skip the part, where you transfer the mail.

Testability has nothing to do with it.

If I use mail functionality in projects, I normally send the mails to one account in the test environment, overriding the original target. But after that, e.i. in integration and qa environments mails are sent allready to the testers.

In automated test either don't test it at all, or mock the call. In any way validation should be done prior to sending a mail.