Guest User

Untitled

a guest
Aug 24th, 2018
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. libraryDependencies += "com.typesafe.play" %% "play-mailer" % "6.0.0"
  2. libraryDependencies += "com.typesafe.play" %% "play-mailer-guice" % "6.0.0"
  3.  
  4. package controllers
  5. import play.api.libs.mailer._
  6. import java.io.File
  7. import java.io.File
  8. import java.io.InputStream
  9. import play.api.Environment
  10. import org.apache.commons.mail.EmailAttachment
  11. import play.api.libs.mailer._
  12. import play.api.mvc.{AbstractController, Action, Controller, ControllerComponents}
  13. import akka.http.scaladsl.model.HttpHeader.ParsingResult.Ok
  14. import org.apache.commons.mail.EmailAttachment
  15. import javax.inject.Inject
  16. import play.api.libs.json.Json
  17. class MailController @Inject()(mailer: MailerClient, environment: Environment) extends Controller {
  18.  
  19. def sendWithCustomMailer = Action {
  20. // val mailer = new SMTPMailer(SMTPConfiguration("typesafe.org", 1234))
  21. // val id = mailer.send(Email("Simple email", "Mister FROM <abhinaykumar499@gmail.com>"))
  22.  
  23. val emailfrom="xxxxxx@gmail.com"
  24. val emailto="yyyyyyyyy@gmail.com"
  25. val subject ="Simple Email"
  26. val bodytext="A text message";
  27.  
  28. val email = Email("Simple email", ""+emailfrom+"", Seq(""+emailto+""), bodyText = Some("A text message"))
  29. mailer.send(email)
  30.  
  31. Ok(s"Email sent!")
  32. }
  33.  
  34. play.mailer {
  35. smtp.host = "smtp.gmail.com" // (mandatory)
  36. port = 465// (defaults to 25)
  37. ssl = true // (defaults to no)
  38. tls = false // (defaults to no)
  39. tlsRequired =false // (defaults to no)
  40. user = "xxxxxx@gmail.com" // (optional)
  41. password = "12121212" // (optional)
  42. // debug = false // (defaults to no, to take effect you also need to set the log level to "DEBUG" for the application logger)
  43. timeout = 600 // (defaults to 60s in milliseconds)
  44. connectiontimeout = 600 // (defaults to 60s in milliseconds)
  45. mock = true // (defaults to no, will only log all the email properties instead of sending an email)
  46. }
Add Comment
Please, Sign In to add comment