- 1、本文档共9页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 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-
您可能关注的文档
- PEP小学英语三年级上册各单元教学目标.docx
- PEP小学英语三年级下册期末试卷 .docx
- pep小学英语时态总结.docx
- PEP小学英语四年级下册Unit5《My clothes》Part B 教学设计.docx
- PEP小学英语四年级下册第二单元测试题 .docx
- pep小学英语四年级下册教学计划.docx
- PEP小学英语四年级下册期中测试题.docx
- PEP小学英语五年级第五六单元测试题.docx
- PEP小学英语五年级上册Recycle 1教案.docx
- PEP小学英语五年级上册Recycle1时教学案例与反思.docx
- 两个相干源产生波具有3b chmc.pdf
- wifi高性能模块ce fcc rohs认证-xrf report电子档.pdf
- linux pci multiport installation manual多端口安装手册.pdf
- 二章基本概念理论.pdf
- 互联网工程任务组ietfs turnerrfc5940 txt.pdf
- mtz0数学高级证明集合关系群mathematics paper 3 sets relations and groups french.pdf
- 网上书店需求规格说明.pdf
- 系统测试用例pcweb终端.pdf
- apv1 keil环境下接口兼容问题.pdf
- 2023届江西省八所重点中学高三3月联考英语试题(原卷版).docx
文档评论(0)