Mercurial Hosting > nabble
view src/nabble/view/lib/ChangeEmailMail.jtp @ 0:7ecd1a4ef557
add content
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 21 Mar 2019 19:15:52 -0600 |
parents | |
children |
line wrap: on
line source
<% package nabble.view.lib; import fschmidt.util.mail.AlternativeMultipartContent; import fschmidt.util.mail.Content; import fschmidt.util.mail.Mail; import fschmidt.util.mail.MailAddress; import fschmidt.util.mail.MailException; import fschmidt.util.mail.MailHome; import fschmidt.util.mail.PlainTextContent; import fschmidt.util.mail.TextContent; import nabble.model.ModelHome; import nabble.model.Site; import java.io.PrintWriter; import java.io.StringWriter; public class ChangeEmailMail { public static void send(Site site, String username, String oldEmail, String newEmail, String url) { StringWriter content = new StringWriter(); PrintWriter out = new PrintWriter(content); // text part %> Dear <%=username%>, You or the administrator of "<%=site.getRootNode().getSubject()%>" wants to change the email address of your user account. Username: <%=username%> Old email address: <%=oldEmail%> New email address: <%=newEmail%> Please click on the link below if you want to confirm this change: <%=url%> If you didn't request this email or have no idea why you received it, please ignore it. Regards, The Nabble Team <% out.flush(); String text = content.toString(); content.getBuffer().setLength(0); // aol part %> Dear <%=username%>, You or the administrator of "<%=site.getRootNode().getSubject()%>" wants to change the email address of your user account. Username: <%=username%> Old email address: <%=oldEmail%> New email address: <%=newEmail%> Please click on the link below if you want to confirm this change: <a href="<%=url%>"><%=url%></a> If you didn't request this email or have no idea why you received it, please ignore it. Regards, The Nabble Team <% out.flush(); String aol = content.toString(); out.close(); try { Mail mail = MailHome.newMail(); mail.setFrom( new MailAddress(ModelHome.noReply) ); mail.setTo( new MailAddress(newEmail) ); mail.setSubject( "Email Change" ); mail.setContent( new AlternativeMultipartContent(new Content[]{ new PlainTextContent(text), new TextContent("x-aol",aol), }) ); ModelHome.send(mail); } catch(MailException e) { throw new RuntimeException(e); } } } %>