Created
August 23, 2015 19:01
-
-
Save ggrossetie/8b4998374843beff58cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
play { | |
modules { | |
disabled += "play.api.libs.mailer.SMTPConfigurationModule" | |
enabled += "controllers.CustomMailerConfigurationModule" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]>")) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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