我可以在不使用系统属性的情况下使用 Scala/Lift 发送电子邮件吗?

发布于 2024-12-17 17:53:59 字数 278 浏览 1 评论 0原文

我想实现一个简单的电子邮件发送功能,因为


object SendEmail {
  apply(smtpServer: String, login: String, password: String, from: String, subject: String, message: String) {
    //... implementation...
  }
}

我发现的所有示例都设置系统属性来初始化邮件传输,但我希望拥有这种简单、灵活和并发安全的功能。这可能吗?

I'd like to implement a simple e-mail sending function as


object SendEmail {
  apply(smtpServer: String, login: String, password: String, from: String, subject: String, message: String) {
    //... implementation...
  }
}

All the examples I've found set system properties to initialize a mail transport, but I'd like to have that simple, flexible and concurrency-safe function. Is this possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落花浅忆 2024-12-24 17:53:59

我不知道这对您来说是否足够,但是您可以创建一个这样的会话:

javax.mail.Session.getInstance(props)

props 是一个 java.util.Properties (您是指系统属性吗?)实例。

然后您可以创建消息。

I don't know if that is sufficient for you, but you can create a session like that:

javax.mail.Session.getInstance(props)

props being a java.util.Properties (did you mean that by system properties?) instance.

Then you can create a message.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文