Skip to content

Instantly share code, notes, and snippets.

@ggrossetie
Created August 23, 2015 19:01
Show Gist options
  • Save ggrossetie/8b4998374843beff58cb to your computer and use it in GitHub Desktop.
Save ggrossetie/8b4998374843beff58cb to your computer and use it in GitHub Desktop.
play {
modules {
disabled += "play.api.libs.mailer.SMTPConfigurationModule"
enabled += "controllers.CustomMailerConfigurationModule"
}
}
class CustomSMTPConfigurationProvider extends Provider[SMTPConfiguration] {
override def get() = new SMTPConfiguration("typesafe.org", 1234)
}
class CustomMailerConfigurationModule extends Module {
def bindings(environment: Environment, configuration: Configuration) = Seq(
bind[SMTPConfiguration].toProvider[CustomSMTPConfigurationProvider]
)
}
class ImmutableConfigure @Inject()(mailer: MailerClient) {
def send() {
val mailer = new SMTPMailer(SMTPConfiguration("typesafe.org", 1234))
val id = mailer.send(Email("Simple email", "Mister FROM <[email protected]>"))
}
}
class MutableConfigure @Inject()(mailer: MailerClient) {
def send() {
val email = Email("Simple email", "[email protected]", Seq("[email protected]"))
val id = mailer.configure(Configuration.from(Map("host" -> "typesafe.org", "port" -> 1234))).send(email)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment