Sending emails from java applications, esp. dropwizard apps - "best" ways

2,026 views
Skip to first unread message

Colin McEnearney

unread,
Nov 7, 2013, 7:14:07 PM11/7/13
to dropwiz...@googlegroups.com
Hi,

I am building my first service with dropwizard and really enjoying how sensible and pain-free it is. I know this is a little off topic, but now I need to send some emails as part of the service and thought, if dropwizard itself is any indication, members of this group will be a great source of wisdom.

Can anyone recommend any particular approaches for sending emails from a java app?

Thanks,
Colin

Carlo Barbara

unread,
Nov 8, 2013, 9:35:32 AM11/8/13
to dropwiz...@googlegroups.com
I think your decision depends on the volume and feature requirements.

For quick and dirty, you can roll your own function and have your service send it to an smtp server. I've included a simple example, which is based on the SmtpAppender in logback

If you want tracking, segmentation, engagement campaigns, help with spam filtering, etc. you will probably want to engage with a vendor thru their api. Some example vendors are SailThru and Cheetahmail

Another thing to consider is sending all of your email messages to a queue, and having worker processes send the emails. Whether the consumers are a vendor api, or your own code, it provides more flexibility down the road.









--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-us...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Lance N.

unread,
Nov 8, 2013, 4:19:13 PM11/8/13
to dropwiz...@googlegroups.com
Haven't used it, but Java includes a mail library.

Matias Surdi

unread,
Nov 8, 2013, 5:00:05 PM11/8/13
to dropwiz...@googlegroups.com
You might find useful Apache Commons Email too.

Colin McEnearney

unread,
Nov 8, 2013, 6:53:14 PM11/8/13
to dropwiz...@googlegroups.com
Well, I had been struggling with javax.mail for a while before posting and just realized that there was a firewall issue actually :-)

Apache Commons Email looks really nice.

And I will definitely have to look into using a queue + worker processes

Thanks!


--
You received this message because you are subscribed to a topic in the Google Groups "dropwizard-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dropwizard-user/Xt_IFEOWuHQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dropwizard-us...@googlegroups.com.

Brian Nesbitt

unread,
Nov 9, 2013, 9:27:10 PM11/9/13
to dropwiz...@googlegroups.com
If you want to outsource the sending I just integrated http://aws.amazon.com/ses/ into a dropwizard app.  Using their http://aws.amazon.com/sdkforjava/ it doesn't take very long before you are getting emails to an inbox.

There are others available... 

Colin McEnearney

unread,
Nov 9, 2013, 11:21:06 PM11/9/13
to dropwiz...@googlegroups.com
Thanks!

I am using Mandrill atm but very glad to hear of these as well. 

In case anyone is interested, this is a very basic working example with Apache Commons Email + Mandrill





Rakesh Waghela

unread,
Nov 13, 2013, 4:13:48 AM11/13/13
to dropwiz...@googlegroups.com
https://code.google.com/p/simple-java-mail/

works great, for sending emails. Don't forget to make it asynchronous via some worker thread because email sending is a IO heavy task which may fail..
Reply all
Reply to author
Forward
0 new messages