在游戏 1.2.4 中。您可以使用标准模板机制和语法发送复杂的动态电子邮件(link http://www.playframework.org/documentation/1.2.4/emails),虽然我没用过,但看起来真的很酷。是个邮件插件 https://github.com/typesafehub/play-plugins/tree/master/mailerPlay2.0能干这种事吗?
如果“复杂的动态电子邮件”是指基于模板的 HTML 电子邮件正文,则可以使用 Play 2.0 执行相同的操作。
例如,您只需根据模板创建一个新视图mailBody.scala.html
:
@(user:User)
<h3>Welcome @user.name</h3>
<br/>
....
然后,在发送电子邮件的方法中,您只需调用render()
你的观点的方法:
public static void sendMail(User user) {
MailerAPI mail = play.Play.application().plugin(MailerPlugin.class).email();
mail.setSubject(...);
mail.addRecipient(user.email);
mail.addFrom(...);
String body = views.html.mailBody.render(user).body();
mail.sendHtml(body);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)