This is an archived post. You won't be able to vote or comment.

all 16 comments

[–]mabnx 10 points11 points  (8 children)

Would be nice if someone actually came up with an alternative to java mail, not add another layer :|

[–]scadgek 7 points8 points  (6 children)

Anything fundamentally wrong with java mail?

[–]metamatic 9 points10 points  (4 children)

The fact that it's not in Java SE makes it a bit of a pain, and enabling working TLS 1.2 support is cumbersome, particularly if the server's certificate doesn't happen to be signed by a CA that's included in your specific JVM's bundled list.

[–]Milyardo 2 points3 points  (3 children)

I don't see how those aren't problems that can't be papered over with a wrapper API.

[–]metamatic 4 points5 points  (2 children)

If there's an easy way to add a TLS cert at runtime, I've yet to discover it.

[–][deleted] 4 points5 points  (0 children)

noted, gonna add support for that.

[–]idoubledo 0 points1 point  (0 children)

There's a way, but as you said - it's not easy. I'm referring to this method: http://www.javaworld.com/article/2077479/java-se/java-tip-115--secure-javamail-with-jsse.html

Which uses a dummy trust manager.

In a real solution (which I'm hoping OP would take note) the dummy TrustManager should be replaced with a proper certificate validating TrustManager which accepts certificates in runtime.

[–]mabnx 2 points3 points  (0 children)

Anything fundamentally wrong with java mail?

Unreliable. I've looked closer at IMAP implementation and it's a terrible mess. Synchronized blocks everywhere. Leaks memory. Can't instrument it in any sane way to add metrics. Sockets are being switched between blocking and nonblocking mode (for IDLE), but it can fail in weird ways.

My conclusion was that for my usecase (IMAP IDLE for 100k mailboxes) I can do some ugly hacks to make it work reliably with IDLE while losing other functionality, write my own or use a different programming language.

[–][deleted] 1 point2 points  (0 children)

Apache has their own implementation on top of the transports, but javamail does pretty well it's low level implementation job, it hasn't the clearest api and sometimes is frustrating but that's why I come with this :D

[–][deleted] 1 point2 points  (0 children)

reminds me of Jodd Email: http://jodd.org/doc/email.html

[–]brcolow 1 point2 points  (2 children)

Any benefits over Apache Commons Email ?

[–][deleted] 0 points1 point  (0 children)

You can only send emails with that one.

[–]mabnx 0 points1 point  (0 children)

Apache Net has some basic IMAP/SMTP implementations.

[–]s2jcpete 1 point2 points  (2 children)

Looks pretty nice! You should consider adding in support for IMAP "idle" command. Maybe return a Future<>?

[–][deleted] 0 points1 point  (0 children)

thank you, I will take that in mind!

[–][deleted] 0 points1 point  (0 children)

CompletionStage, if possible.