Play Framework 框架 邮件分析和总结.docx

Play Framework 框架 邮件分析和总结.docx

  1. 1、本文档共9页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
使用 Play 发送邮件 Sending e-mail with Play 你可以使用 play.libs.Mail 工具类容易地发送邮件。 You can use the play.libs.Mail utility to send e-mail very easily: Mail.send(sender@zenexity.fr,recipient@zenexity.fr,S ubject,Message); Mail 和 MVC Mail and MVC integration 你还可以发送复杂的,动态的邮件,使用调准的模板和语法。 You can also send complex, dynamic e-mail using the standard templates mechanism and syntax. 首先,在你的应用中定义一个 Mail notifier,你的 mail notifier 必须是 play.mvc.Mailer 的子类,而且必须在 notifiers 文件夹中。 First, define a **Mailer notifier** in your application. Your mailer notifier must subclass **play.mvc.Mailer** and be part of the **notifiers** package. 每一个 public static 的方法都会是一个邮件发送器,就像 MVC 控制器中的actions 一样。 Each public static method will be an e-mail sender, in a similar manner as actions for a MVC controller. 例如: For example: package notifiers; import play.*; import play.mvc.*; import java.util.*; public class Mails extends Mailer { public static void welcome(User user) { setSubject(Welcome %s, ); addRecipient(user.email); setFrom(Me me@); addAttachment(Play.getFile(rules.pdf)); send(user); } public static void lostPassword(User user) { String newpassword = user.password; setFrom(Robot robot@); setSubject(Your password has been reset); addRecipient(user.email); send(user, newpassword); } } 基于 html 的模板 h3. text/html e-mail 发送器会使用app/views/Mails/welcome.html 模板作为邮件信息的内容。 The send call will render the app/views/Mails/welcome.html template as the e-mail message body. htmlbodypWelcome b${}/b, /p ... /html lostPassword 方法的模板会像这样一样: The template for the lostPassword method could look like this: app/views/Mails/lostPassword.html htmlbodyhead.../headbodyimg src=/images/pHello ${},br/ Your new password is b${newpassword}/b. /p /body /html 自定义的邮件 h3. text/plain e-mail 如果没有定义 HTML 模板,那么自定义的文本邮件会被发送,使用 text 模板。 If no HTML template is defined, then a text/plain e-mail is sent using the text template. 发送器会使用 app/views/Mails/welcome.txt 模板作为邮件信息的内容。 The send call will render the app/views/Mails/welcome.txt template as the e-

文档评论(0)

tianya189 + 关注
官方认证
内容提供者

该用户很懒,什么也没介绍

认证主体阳新县融易互联网技术工作室
IP属地上海
统一社会信用代码/组织机构代码
92420222MA4ELHM75D

1亿VIP精品文档

相关文档