Sending e-mail 使用的是 Apache Commons Email
A simple e-mail:简单的邮件发送
然后是例子代码 package notifiers; import play.*; import play.mvc.*; import java.util.*; public class Mails extends Mailer { public static void welcome(User user) { setSubject("Welcome %s", user.name); addRecipient(user.email); setFrom("Me <me@me.com>"); EmailAttachment attachment = new EmailAttachment(); attachment.setDescription("A pdf document"); attachment.setPath(Play.getFile("rules.pdf").getPath()); addAttachment(attachment); send(user); } public static void lostPassword(User user) { String newpassword = user.password; setFrom("Robot <robot@thecompany.com>"); //注意此处,需要和你的SMTP的HOST账户对应的 setSubject("Your password has been reset"); addRecipient(user.email); send(user, newpassword); //send相当于render,他会去渲染对应的HTML并发送 }
} |
|
来自: 用勿龍潛 > 《play!framework》