播放邮件是一个smtp服务器

问题描述 投票:0回答:1

我需要从我的Play 2.6.x服务器发送电子邮件的功能。我发现我可以使用play-mailerhttps://github.com/playframework/play-mailer#usage

问题1 - 我需要一个单独的smtp服务器,或者play-mailersmtp服务器本身。

问题2 - 目前,我在localhost上运行应用程序,但我最终会部署它。如果我只是在下面的配置中使用localhost,我的应用程序会工作吗?

play.mailer {
  host = localhost // (mandatory)
  port = 25 // (defaults to 25)
  ssl = no // (defaults to no)
  tls = no // (defaults to no)
  tlsRequired = no // (defaults to no)
  user = null // (optional)
  password = null // (optional)
  debug = no // (defaults to no, to take effect you also need to set the log level to "DEBUG" for the application logger)
  timeout = null // (defaults to 60s in milliseconds)
  connectiontimeout = null // (defaults to 60s in milliseconds)
  mock = true// (defaults to no, will only log all the email properties instead of sending an email)
}

问题3 - 一旦我在云中部署应用程序(比如AWS),我是否只需要在上面的配置中更改host以使其工作?

问题4 - 我想在play.mailer配置中传递用户名和密码。考虑到我版本控制我的application.conf,在文件中输入用户名和密码是否安全?

playframework-2.6
1个回答
0
投票

答案1:你需要一个smtp服务器来连接play.mailer。这通常是您在生产中放入主机的内容。

答案2:

是的它应该像那样工作,我认为你必须设置mock = yes

答案3:

如果你决定使用aws(https://aws.amazon.com/ses/),你的conf会看起来像这样。

play.mailer {
  host = "email-smtp.us-east-1.amazonaws.com" // (mandatory) - url from amazon
  port = 465 // (defaults to 25)
  ssl = yes // (defaults to no)
  tls = no // (defaults to no)
  tlsRequired = no // (defaults to no)
  user = "id_from_amazon"
  password = "password_from_amazon"
  debug = no // (defaults to no)
  timeout = null // (defaults to 60s in milliseconds)
  connectiontimeout = null // (defaults to 60s in milliseconds)
  mock = no // for actually sending emails. set it to yes if you want to mock.
}

答案4:

因此,安全方面取决于您使用Play服务器的环境。如果某人可能会看到application.conf,那么您可以使用环境变量而不是在application.conf中编写它。

password = ${APP_MAILER_PASSWORD}

然后将APP_MAILER_PASSWORD设置为环境变量。同样,如果有人可以访问您服务器的控制台,这是不安全的 - 但此时并不多。

© www.soinside.com 2019 - 2024. All rights reserved.