playframework / play-mailer

Play mailer plugin
Apache License 2.0
249 stars 74 forks source link

Create a sendAsync method #13

Open ggrossetie opened 9 years ago

ggrossetie commented 9 years ago

When I send an email I don't want to "block" my process. I'm using Akka to "schedule" the send:

Akka.system.scheduler.scheduleOnce(1.seconds) {
}

Maybe we can add a sendAsync to the API to do that ? or just an example in the documentation ? And it might be better to return a Future ?

jroper commented 9 years ago

Maybe we could implement a reactive mail client? :wink:

ggrossetie commented 9 years ago

or just name the method sendReactive() to give the feeling of reactive :smile:

krispypen commented 9 years ago

:+1: for the reactive mail client :)

screenshot from 2015-07-20 16 38 21

ggrossetie commented 9 years ago

@jroper could you explain what you have in mind ? Provide an implementation of http://www.reactive-streams.org/ ? Rely on Akka for async ? Replace commons-mailer with X ?

Thanks :)

jroper commented 9 years ago

Definitely not provide an implementation of reactive streams. However, we could use Akka streams to implement an asynchronous SMTP client - SMTP is mostly line by line so would be quite simple to parse and implement. But, I was 90% joking - I don't want to maintain an SMTP client.

ggrossetie commented 9 years ago

I was 90% sure you were joking :smile: And what do you think about the initial proposition (i.e. using Akka to schedule the send) ? This is a simple (and maybe dumb solution) but then users can compose futures (using other Play! libraries like WS).

jroper commented 9 years ago

You could also just do:

Future(...)

That will dispatch it asynchronously, and also allow you to add callbacks when it's done.

schmitch commented 8 years ago

@jroper even if it sounds aweful but I think maintaining a akka-mail client has benefits.

Also we wouldn't need to provide a SMTP Mailer, we could drop apache-commons Mail and just use javax.mail (which apache-commons uses internally) we would just drop a dependency that only gives a "nicer" API. But that happens only internally so, the benefit is definitely there by dropping yet another dependency. And Akka is mostly there anyway.