{"action":"created","comment":{"url":"https://api.github.com/repos/playframework/play-mailer/pulls/comments/38288379","id":38288379,"diff_hunk":"@@ -27,9 +26,9 @@ class ApplicationScala @Inject()(mailer: MailerClient) extends Controller {\n     Ok(s\"Email $id sent!\")\n   }\n \n-  def configureAndSend = Action {\n-    val email = Email(\"Simple email\", \"from@email.com\", Seq(\"to@email.com\"))\n-    val id = mailer.configure(Configuration.from(Map(\"host\" -> \"typesafe.org\", \"port\" -> 1234))).send(email)\n+  def sendWithCustomMailer = Action {\n+    val mailer = new SMTPMailer(SMTPConfiguration(\"typesafe.org\", 1234))","path":"samples/runtimeDI/app/controllers/ApplicationScala.scala","position":16,"original_position":16,"commit_id":"b0d85501500f6ea75123539f4acfb20f601ed59b","original_commit_id":"b0d85501500f6ea75123539f4acfb20f601ed59b","user":{"login":"loicdescotte","id":638150,"avatar_url":"https://avatars.githubusercontent.com/u/638150?v=3","gravatar_id":"","url":"https://api.github.com/users/loicdescotte","html_url":"https://github.com/loicdescotte","followers_url":"https://api.github.com/users/loicdescotte/followers","following_url":"https://api.github.com/users/loicdescotte/following{/other_user}","gists_url":"https://api.github.com/users/loicdescotte/gists{/gist_id}","starred_url":"https://api.github.com/users/loicdescotte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loicdescotte/subscriptions","organizations_url":"https://api.github.com/users/loicdescotte/orgs","repos_url":"https://api.github.com/users/loicdescotte/repos","events_url":"https://api.github.com/users/loicdescotte/events{/privacy}","received_events_url":"https://api.github.com/users/loicdescotte/received_events","type":"User","site_admin":false},"body":"Nice, I think it adds a lot of flexibility.  ","created_at":"2015-08-31T07:00:33Z","updated_at":"2015-08-31T07:00:33Z","html_url":"https://github.com/playframework/play-mailer/pull/63#discussion_r38288379","pull_request_url":"https://api.github.com/repos/playframework/play-mailer/pulls/63","_links":{"self":{"href":"https://api.github.com/repos/playframework/play-mailer/pulls/comments/38288379"},"html":{"href":"https://github.com/playframework/play-mailer/pull/63#discussion_r38288379"},"pull_request":{"href":"https://api.github.com/repos/playframework/play-mailer/pulls/63"}}},"pull_request":{"url":"https://api.github.com/repos/playframework/play-mailer/pulls/63","id":42518231,"html_url":"https://github.com/playframework/play-mailer/pull/63","diff_url":"https://github.com/playframework/play-mailer/pull/63.diff","patch_url":"https://github.com/playframework/play-mailer/pull/63.patch","issue_url":"https://api.github.com/repos/playframework/play-mailer/issues/63","number":63,"state":"open","locked":false,"title":"Immutable mailer instance","user":{"login":"Mogztter","id":333276,"avatar_url":"https://avatars.githubusercontent.com/u/333276?v=3","gravatar_id":"","url":"https://api.github.com/users/Mogztter","html_url":"https://github.com/Mogztter","followers_url":"https://api.github.com/users/Mogztter/followers","following_url":"https://api.github.com/users/Mogztter/following{/other_user}","gists_url":"https://api.github.com/users/Mogztter/gists{/gist_id}","starred_url":"https://api.github.com/users/Mogztter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mogztter/subscriptions","organizations_url":"https://api.github.com/users/Mogztter/orgs","repos_url":"https://api.github.com/users/Mogztter/repos","events_url":"https://api.github.com/users/Mogztter/events{/privacy}","received_events_url":"https://api.github.com/users/Mogztter/received_events","type":"User","site_admin":false},"body":"This is a proposition to replace the `configure` method.\r\nCurrently the mailer instance is mutable, when it gets reconfigured, it gets reconfigured globally.\r\nThe goal is to have an immutable mailer instance. See: https://github.com/playframework/play-mailer/issues/51#issuecomment-121798831\r\n\r\n**Principle**\r\n * New module to provide a `SMTPConfiguration` from the `Configuration` object\r\n   * This module can be overridden with `play.modules.disabled` (not sure if this the right way to do it) to provide a custom SMTPConfiguration (see samples)\r\n * CommonsMailer injects a SMTPConfiguration\r\n\r\nNote: I think it would be better to rename `CommonsMailer` to `SMTPMailer` and `SMTPMailer` to `CommonsMailer`.\r\n\r\n**Pros**\r\n * Immutable mailer instance\r\n * If the mailer configuration is wrong, we get an error at the start of the server (i.e. when Guice initializes objects) rather than when the code is executed\r\n * It's easy to (manually) instantiate a mailer with a custom configuration `val mailer = new CommonsMailer(SMTPConfiguration(\"typesafe.org\", 1234))`\r\n\r\n**Cons**\r\n * It's less straight forward to configure the injected instance\r\n   * write custom module and provider + disable the default module and enable the custom module \r\n * \"Cryptic\" error message when the mailer configuration is wrong (because Guice is unable to create a `SMTPConfiguration`)\r\n\r\n ```\r\nProvisionException: Unable to provision, see the following errors:\r\n\r\n1) Error in custom provider, java.lang.RuntimeException: host needs to be set in order to use this plugin (or set play.mailer.mock to true in application.conf)\r\n  while locating play.api.libs.mailer.SMTPConfigurationProvider\r\n  while locating play.api.libs.mailer.SMTPConfiguration\r\n    for parameter 0 at play.api.libs.mailer.CommonsMailer.<init>(MailerPlugin.scala:86)\r\n  while locating play.api.libs.mailer.CommonsMailer\r\n  while locating play.api.libs.mailer.MailerClient\r\n    for parameter 0 at controllers.ApplicationJava.<init>(ApplicationJava.java:18)\r\n  while locating controllers.ApplicationJava\r\n    for parameter 1 at router.Routes.<init>(Routes.scala:32)\r\n  while locating router.Routes\r\n  while locating play.api.inject.RoutesProvider\r\n  while locating play.api.routing.Router\r\nCaused by: java.lang.RuntimeException: host needs to be set in order to use this plugin (or set play.mailer.mock to true in application.conf)\r\n```\r\n * Not binary compatible","created_at":"2015-08-15T11:53:35Z","updated_at":"2015-08-31T07:00:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3be0b5b08dc5ba50f994da0fa1907fc23370e71d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/playframework/play-mailer/pulls/63/commits","review_comments_url":"https://api.github.com/repos/playframework/play-mailer/pulls/63/comments","review_comment_url":"https://api.github.com/repos/playframework/play-mailer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/playframework/play-mailer/issues/63/comments","statuses_url":"https://api.github.com/repos/playframework/play-mailer/statuses/b0d85501500f6ea75123539f4acfb20f601ed59b","head":{"label":"Mogztter:immutable","ref":"immutable","sha":"b0d85501500f6ea75123539f4acfb20f601ed59b","user":{"login":"Mogztter","id":333276,"avatar_url":"https://avatars.githubusercontent.com/u/333276?v=3","gravatar_id":"","url":"https://api.github.com/users/Mogztter","html_url":"https://github.com/Mogztter","followers_url":"https://api.github.com/users/Mogztter/followers","following_url":"https://api.github.com/users/Mogztter/following{/other_user}","gists_url":"https://api.github.com/users/Mogztter/gists{/gist_id}","starred_url":"https://api.github.com/users/Mogztter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mogztter/subscriptions","organizations_url":"https://api.github.com/users/Mogztter/orgs","repos_url":"https://api.github.com/users/Mogztter/repos","events_url":"https://api.github.com/users/Mogztter/events{/privacy}","received_events_url":"https://api.github.com/users/Mogztter/received_events","type":"User","site_admin":false},"repo":{"id":25937364,"name":"play-mailer","full_name":"Mogztter/play-mailer","owner":{"login":"Mogztter","id":333276,"avatar_url":"https://avatars.githubusercontent.com/u/333276?v=3","gravatar_id":"","url":"https://api.github.com/users/Mogztter","html_url":"https://github.com/Mogztter","followers_url":"https://api.github.com/users/Mogztter/followers","following_url":"https://api.github.com/users/Mogztter/following{/other_user}","gists_url":"https://api.github.com/users/Mogztter/gists{/gist_id}","starred_url":"https://api.github.com/users/Mogztter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mogztter/subscriptions","organizations_url":"https://api.github.com/users/Mogztter/orgs","repos_url":"https://api.github.com/users/Mogztter/repos","events_url":"https://api.github.com/users/Mogztter/events{/privacy}","received_events_url":"https://api.github.com/users/Mogztter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Mogztter/play-mailer","description":"Play mailer plugin","fork":true,"url":"https://api.github.com/repos/Mogztter/play-mailer","forks_url":"https://api.github.com/repos/Mogztter/play-mailer/forks","keys_url":"https://api.github.com/repos/Mogztter/play-mailer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Mogztter/play-mailer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Mogztter/play-mailer/teams","hooks_url":"https://api.github.com/repos/Mogztter/play-mailer/hooks","issue_events_url":"https://api.github.com/repos/Mogztter/play-mailer/issues/events{/number}","events_url":"https://api.github.com/repos/Mogztter/play-mailer/events","assignees_url":"https://api.github.com/repos/Mogztter/play-mailer/assignees{/user}","branches_url":"https://api.github.com/repos/Mogztter/play-mailer/branches{/branch}","tags_url":"https://api.github.com/repos/Mogztter/play-mailer/tags","blobs_url":"https://api.github.com/repos/Mogztter/play-mailer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Mogztter/play-mailer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Mogztter/play-mailer/git/refs{/sha}","trees_url":"https://api.github.com/repos/Mogztter/play-mailer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Mogztter/play-mailer/statuses/{sha}","languages_url":"https://api.github.com/repos/Mogztter/play-mailer/languages","stargazers_url":"https://api.github.com/repos/Mogztter/play-mailer/stargazers","contributors_url":"https://api.github.com/repos/Mogztter/play-mailer/contributors","subscribers_url":"https://api.github.com/repos/Mogztter/play-mailer/subscribers","subscription_url":"https://api.github.com/repos/Mogztter/play-mailer/subscription","commits_url":"https://api.github.com/repos/Mogztter/play-mailer/commits{/sha}","git_commits_url":"https://api.github.com/repos/Mogztter/play-mailer/git/commits{/sha}","comments_url":"https://api.github.com/repos/Mogztter/play-mailer/comments{/number}","issue_comment_url":"https://api.github.com/repos/Mogztter/play-mailer/issues/comments{/number}","contents_url":"https://api.github.com/repos/Mogztter/play-mailer/contents/{+path}","compare_url":"https://api.github.com/repos/Mogztter/play-mailer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Mogztter/play-mailer/merges","archive_url":"https://api.github.com/repos/Mogztter/play-mailer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Mogztter/play-mailer/downloads","issues_url":"https://api.github.com/repos/Mogztter/play-mailer/issues{/number}","pulls_url":"https://api.github.com/repos/Mogztter/play-mailer/pulls{/number}","milestones_url":"https://api.github.com/repos/Mogztter/play-mailer/milestones{/number}","notifications_url":"https://api.github.com/repos/Mogztter/play-mailer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Mogztter/play-mailer/labels{/name}","releases_url":"https://api.github.com/repos/Mogztter/play-mailer/releases{/id}","created_at":"2014-10-29T19:21:05Z","updated_at":"2015-01-13T10:12:32Z","pushed_at":"2015-08-30T11:58:48Z","git_url":"git://github.com/Mogztter/play-mailer.git","ssh_url":"git@github.com:Mogztter/play-mailer.git","clone_url":"https://github.com/Mogztter/play-mailer.git","svn_url":"https://github.com/Mogztter/play-mailer","homepage":null,"size":593,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"playframework:master","ref":"master","sha":"f2de34131208f138b267c29754f628d62325f042","user":{"login":"playframework","id":319107,"avatar_url":"https://avatars.githubusercontent.com/u/319107?v=3","gravatar_id":"","url":"https://api.github.com/users/playframework","html_url":"https://github.com/playframework","followers_url":"https://api.github.com/users/playframework/followers","following_url":"https://api.github.com/users/playframework/following{/other_user}","gists_url":"https://api.github.com/users/playframework/gists{/gist_id}","starred_url":"https://api.github.com/users/playframework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/playframework/subscriptions","organizations_url":"https://api.github.com/users/playframework/orgs","repos_url":"https://api.github.com/users/playframework/repos","events_url":"https://api.github.com/users/playframework/events{/privacy}","received_events_url":"https://api.github.com/users/playframework/received_events","type":"Organization","site_admin":false},"repo":{"id":25909546,"name":"play-mailer","full_name":"playframework/play-mailer","owner":{"login":"playframework","id":319107,"avatar_url":"https://avatars.githubusercontent.com/u/319107?v=3","gravatar_id":"","url":"https://api.github.com/users/playframework","html_url":"https://github.com/playframework","followers_url":"https://api.github.com/users/playframework/followers","following_url":"https://api.github.com/users/playframework/following{/other_user}","gists_url":"https://api.github.com/users/playframework/gists{/gist_id}","starred_url":"https://api.github.com/users/playframework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/playframework/subscriptions","organizations_url":"https://api.github.com/users/playframework/orgs","repos_url":"https://api.github.com/users/playframework/repos","events_url":"https://api.github.com/users/playframework/events{/privacy}","received_events_url":"https://api.github.com/users/playframework/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/playframework/play-mailer","description":"Play mailer plugin","fork":false,"url":"https://api.github.com/repos/playframework/play-mailer","forks_url":"https://api.github.com/repos/playframework/play-mailer/forks","keys_url":"https://api.github.com/repos/playframework/play-mailer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/playframework/play-mailer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/playframework/play-mailer/teams","hooks_url":"https://api.github.com/repos/playframework/play-mailer/hooks","issue_events_url":"https://api.github.com/repos/playframework/play-mailer/issues/events{/number}","events_url":"https://api.github.com/repos/playframework/play-mailer/events","assignees_url":"https://api.github.com/repos/playframework/play-mailer/assignees{/user}","branches_url":"https://api.github.com/repos/playframework/play-mailer/branches{/branch}","tags_url":"https://api.github.com/repos/playframework/play-mailer/tags","blobs_url":"https://api.github.com/repos/playframework/play-mailer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/playframework/play-mailer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/playframework/play-mailer/git/refs{/sha}","trees_url":"https://api.github.com/repos/playframework/play-mailer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/playframework/play-mailer/statuses/{sha}","languages_url":"https://api.github.com/repos/playframework/play-mailer/languages","stargazers_url":"https://api.github.com/repos/playframework/play-mailer/stargazers","contributors_url":"https://api.github.com/repos/playframework/play-mailer/contributors","subscribers_url":"https://api.github.com/repos/playframework/play-mailer/subscribers","subscription_url":"https://api.github.com/repos/playframework/play-mailer/subscription","commits_url":"https://api.github.com/repos/playframework/play-mailer/commits{/sha}","git_commits_url":"https://api.github.com/repos/playframework/play-mailer/git/commits{/sha}","comments_url":"https://api.github.com/repos/playframework/play-mailer/comments{/number}","issue_comment_url":"https://api.github.com/repos/playframework/play-mailer/issues/comments{/number}","contents_url":"https://api.github.com/repos/playframework/play-mailer/contents/{+path}","compare_url":"https://api.github.com/repos/playframework/play-mailer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/playframework/play-mailer/merges","archive_url":"https://api.github.com/repos/playframework/play-mailer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/playframework/play-mailer/downloads","issues_url":"https://api.github.com/repos/playframework/play-mailer/issues{/number}","pulls_url":"https://api.github.com/repos/playframework/play-mailer/pulls{/number}","milestones_url":"https://api.github.com/repos/playframework/play-mailer/milestones{/number}","notifications_url":"https://api.github.com/repos/playframework/play-mailer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/playframework/play-mailer/labels{/name}","releases_url":"https://api.github.com/repos/playframework/play-mailer/releases{/id}","created_at":"2014-10-29T07:30:48Z","updated_at":"2015-08-30T09:52:30Z","pushed_at":"2015-08-30T11:58:48Z","git_url":"git://github.com/playframework/play-mailer.git","ssh_url":"git@github.com:playframework/play-mailer.git","clone_url":"https://github.com/playframework/play-mailer.git","svn_url":"https://github.com/playframework/play-mailer","homepage":null,"size":907,"stargazers_count":92,"watchers_count":92,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":39,"mirror_url":null,"open_issues_count":6,"forks":39,"open_issues":6,"watchers":92,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/playframework/play-mailer/pulls/63"},"html":{"href":"https://github.com/playframework/play-mailer/pull/63"},"issue":{"href":"https://api.github.com/repos/playframework/play-mailer/issues/63"},"comments":{"href":"https://api.github.com/repos/playframework/play-mailer/issues/63/comments"},"review_comments":{"href":"https://api.github.com/repos/playframework/play-mailer/pulls/63/comments"},"review_comment":{"href":"https://api.github.com/repos/playframework/play-mailer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/playframework/play-mailer/pulls/63/commits"},"statuses":{"href":"https://api.github.com/repos/playframework/play-mailer/statuses/b0d85501500f6ea75123539f4acfb20f601ed59b"}}}}