play-mailer是smtp服务器吗
Is play-mailer an smtp server
我需要从我的 Play 2.6.x
服务器发送电子邮件的功能。我发现我可以使用 play-mailer
(https://github.com/playframework/play-mailer#usage)
问题 1 - 我需要一个单独的 smtp
服务器还是 play-mailer
一个 smtp
服务器本身。
问题 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
进行版本控制,在文件中输入用户名和密码是否安全?
答案一:
您需要一个 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:
所以安全方面取决于你在什么环境下使用你的播放服务器。如果 application.conf 很可能被某人看到那么你可以使用环境变量而不是将它写在 application.conf
password = ${APP_MAILER_PASSWORD}
然后设置APP_MAILER_PASSWORD为环境变量。同样,如果有人可以访问您服务器的控制台,这将是不安全的 - 但此时并不多。
我需要从我的 Play 2.6.x
服务器发送电子邮件的功能。我发现我可以使用 play-mailer
(https://github.com/playframework/play-mailer#usage)
问题 1 - 我需要一个单独的 smtp
服务器还是 play-mailer
一个 smtp
服务器本身。
问题 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
进行版本控制,在文件中输入用户名和密码是否安全?
答案一: 您需要一个 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:
所以安全方面取决于你在什么环境下使用你的播放服务器。如果 application.conf 很可能被某人看到那么你可以使用环境变量而不是将它写在 application.conf
password = ${APP_MAILER_PASSWORD}
然后设置APP_MAILER_PASSWORD为环境变量。同样,如果有人可以访问您服务器的控制台,这将是不安全的 - 但此时并不多。