-
-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Immutable mailer instance #63
Conversation
71d5b2f
to
a1c84c8
Compare
I'm also not a guice Guy, however on my side this looks really good, since that enables configuration via the database (which is what I want) and it is also immutable. Also it's really hard to use it to create multiple Immutable mailers (you need to do a https://github.com/google/guice/wiki/AssistedInject for that (which is hard especially without any example code, for the most people)). But I don't think that too many people will need it without having that knowledge, so we could just ignore this for a while. For the binary incompatible change, I didn't understand the rise to 3.0 (way too early, so I think not many people are on 3.0 yet so we could also just force them to ignore 3.0 or raise to 4.0) |
It's pretty simple to do it without Guice: val email = Email("Simple email", "Mister FROM <[email protected]>")
new SMTPMailer(SMTPConfiguration("typesafe.org", 1234)).send(email)
new SMTPMailer(SMTPConfiguration("playframework.com", 5678)).send(email) |
I've added a detailed explanation on how to configure the mailer instance: https://github.com/Mogztter/play-mailer/blob/immutable/user-manual.adoc @jroper If this looks good to you, I would like to proceed with this pull request and release a |
@loicdescotte If you have some time to do a review that would be awesome ! 😄 |
09e1865
to
cc1859b
Compare
val email = Email("Simple email", "[email protected]", Seq("[email protected]")) | ||
val id = mailer.configure(Configuration.from(Map("host" -> "typesafe.org", "port" -> 1234))).send(email) | ||
def sendWithCustomMailer = Action { | ||
val mailer = new SMTPMailer(SMTPConfiguration("typesafe.org", 1234)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I think it adds a lot of flexibility.
@Mogztter I've just read the code and it seems great :) |
@loicdescotte Thanks for the review |
This is a proposition to replace the
configure
method.Currently the mailer instance is mutable, when it gets reconfigured, it gets reconfigured globally.
The goal is to have an immutable mailer instance. See: #51 (comment)
Principle
SMTPConfiguration
from theConfiguration
objectplay.modules.disabled
(not sure if this the right way to do it) to provide a custom SMTPConfiguration (see samples)Note: I think it would be better to rename
CommonsMailer
toSMTPMailer
andSMTPMailer
toCommonsMailer
.Pros
val mailer = new CommonsMailer(SMTPConfiguration("typesafe.org", 1234))
Cons
It's less straight forward to configure the injected instance
"Cryptic" error message when the mailer configuration is wrong (because Guice is unable to create a
SMTPConfiguration
)Not binary compatible