如何在 Java/Grails 中创建我自己的 SMTP 服务器来发送电子邮件?
How to create my own SMTP Server in Java/Grails to send Emails?
我使用 Grails 2.4.5 和 Mail Plugin。我不想使用外部 SMTP 服务器从我的 Grails 服务器发送电子邮件。相反,我想通过我自己的 SMTP 服务器从我的 Grails 应用程序发送电子邮件。
我找到了subethasmtp,好像是用来接收邮件的,但我需要将它们发送到其他用户的收件箱。
如何创建发送电子邮件的 SMTP 服务器?
那里有大量的 SMTP 服务,其中大部分可能提供免费套餐。我使用(并且喜欢)山魈 (http://blog.mandrill.com/new-simpler-pricing.html), but have heard good things about MailGun, SendGrid, and others. You can also browse a list of alternative solutions here (http://alternativeto.net/software/mandrill/).
要将 SMTP 服务与您的应用程序集成:
- 将邮件插件添加到您的应用程序 (https://grails.org/plugin/mail)
- 使用您想要的 SMTP 服务注册一个帐户
- 为您的应用程序创建一个新的 API 密钥(在 SMTP 服务中)
- 将 SMTP 属性添加到您的外部配置文件 (~/.grails/appName-config.properties) -- 假设已启用
这是一个使用 Mandrill 的示例配置:
grails.mail.from = you@yourcompany.com
grails.mail.host = smtp.mandrillapp.com
grails.mail.port = 587
grails.mail.username = <mandrill-username>
grails.mail.password = <mandrill-apikey>
我使用 Grails 2.4.5 和 Mail Plugin。我不想使用外部 SMTP 服务器从我的 Grails 服务器发送电子邮件。相反,我想通过我自己的 SMTP 服务器从我的 Grails 应用程序发送电子邮件。
我找到了subethasmtp,好像是用来接收邮件的,但我需要将它们发送到其他用户的收件箱。
如何创建发送电子邮件的 SMTP 服务器?
那里有大量的 SMTP 服务,其中大部分可能提供免费套餐。我使用(并且喜欢)山魈 (http://blog.mandrill.com/new-simpler-pricing.html), but have heard good things about MailGun, SendGrid, and others. You can also browse a list of alternative solutions here (http://alternativeto.net/software/mandrill/).
要将 SMTP 服务与您的应用程序集成:
- 将邮件插件添加到您的应用程序 (https://grails.org/plugin/mail)
- 使用您想要的 SMTP 服务注册一个帐户
- 为您的应用程序创建一个新的 API 密钥(在 SMTP 服务中)
- 将 SMTP 属性添加到您的外部配置文件 (~/.grails/appName-config.properties) -- 假设已启用
这是一个使用 Mandrill 的示例配置:
grails.mail.from = you@yourcompany.com
grails.mail.host = smtp.mandrillapp.com
grails.mail.port = 587
grails.mail.username = <mandrill-username>
grails.mail.password = <mandrill-apikey>