我目前正在使用 Ktor Netty 引擎创建我的应用程序
我在文档中搜索了当用户向我的服务器发送请求时处理发送电子邮件的任何功能,但什么也没找到。
post("/api/v1/auth") {
// TODO send email when request is sent!
}
Run Code Online (Sandbox Code Playgroud)
Ktor apache-email-commons 中有一个可用的 java 依赖项
implementation("org.apache.commons:commons-email:1.5")
Run Code Online (Sandbox Code Playgroud)
然后使用 SMTP 服务器,例如 Gmail:
val email = SimpleEmail()
email.hostName = "smtp.googlemail.com"
email.setSmtpPort(465)
email.setAuthenticator(DefaultAuthenticator("email-account", "account-password"))
email.isSSLOnConnect = true
email.setFrom("sender-email-account")
email.subject = "email-subject"
email.setMsg("message-content")
email.addTo("target-email-address")
email.send()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2996 次 |
| 最近记录: |