2013-12-08 47 views
0

如何使用帶Mailer API的play 2.0.4框架在電子郵件正文中發送帳戶驗證鏈接。下面是代碼使用play 2.0在電子郵件正文中發送URL

MailerAPI mail = play.Play.application().plugin(MailerPlugin.class).email();   
mail.setSubject("Complete Your Registration"); 
mail.addFrom(" Live Events<[email protected]>"); 
mail.addRecipient(formUser.email); 
String mailBody = "Please Click on the Below Link to Complete Your Registration 
"localhost:9000/verifyUser?email="+ formUser.email + "&verifyCode=" + formUser.verifierCode; 
mail.send(mailBody); 

我檢查,我發現像這樣的文件,但其發揮1.2.3

URL url = new URL("http://www.zenexity.fr/wp-content/themes/images/logo.png"); 
String cid = email.embed(url, "Zenexity logo"); 

任何想法?

感謝

回答

1

只要發送您的留言HTML與<a>標籤環繞您的網址。

String mailBody = "Please Click on the Below Link to Complete Your Registration 
"<a href=\"http://localhost:9000/verifyUser?email="+ formUser.email + "&verifyCode=" + formUser.verifierCode + "\">click here</a>"; 
... 
mailer.sendHtml(mailBody); 
+0

由於它的工作:) – Wearybands

+1

更重要的是,我建議用普通模板建立HTML郵件,你需要使用它的使用即:'字符串htmlBody = views.html.mail.render(PARAMS )的ToString()' – biesior

相關問題