play-mailer icon indicating copy to clipboard operation
play-mailer copied to clipboard

Create a sendAsync method

Open ggrossetie opened this issue 10 years ago • 8 comments

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 ?

ggrossetie avatar Dec 08 '14 12:12 ggrossetie

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

jroper avatar Dec 08 '14 12:12 jroper

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

ggrossetie avatar Dec 08 '14 21:12 ggrossetie

:+1: for the reactive mail client :)

screenshot from 2015-07-20 16 38 21

krispypen avatar Jul 20 '15 14:07 krispypen

@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 :)

ggrossetie avatar Jul 20 '15 15:07 ggrossetie

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.

jroper avatar Aug 03 '15 10:08 jroper

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

ggrossetie avatar Aug 03 '15 17:08 ggrossetie

You could also just do:

Future(...)

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

jroper avatar Aug 03 '15 23:08 jroper

@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.

schmitch avatar Dec 04 '15 12:12 schmitch