0
|
1
|
|
2 package nabble.view.lib;
|
|
3
|
|
4 import fschmidt.util.mail.AlternativeMultipartContent;
|
|
5 import fschmidt.util.mail.Content;
|
|
6 import fschmidt.util.mail.Mail;
|
|
7 import fschmidt.util.mail.MailAddress;
|
|
8 import fschmidt.util.mail.MailException;
|
|
9 import fschmidt.util.mail.MailHome;
|
|
10 import fschmidt.util.mail.PlainTextContent;
|
|
11 import fschmidt.util.mail.TextContent;
|
|
12 import nabble.model.ModelHome;
|
|
13 import nabble.model.Site;
|
|
14
|
|
15 import java.io.PrintWriter;
|
|
16 import java.io.StringWriter;
|
|
17
|
|
18
|
|
19 public class ChangeEmailMail {
|
|
20
|
|
21 public static void send(Site site, String username, String oldEmail, String newEmail, String url) {
|
|
22 StringWriter content = new StringWriter();
|
|
23 PrintWriter out = new PrintWriter(content);
|
|
24 // text part
|
|
25
|
|
26 out.print( "\r\nDear " );
|
|
27 out.print( (username) );
|
|
28 out.print( ",\r\n\r\nYou or the administrator of \"" );
|
|
29 out.print( (site.getRootNode().getSubject()) );
|
|
30 out.print( "\" wants to change the email address of your user account.\r\nUsername: " );
|
|
31 out.print( (username) );
|
|
32 out.print( "\r\nOld email address: " );
|
|
33 out.print( (oldEmail) );
|
|
34 out.print( "\r\nNew email address: " );
|
|
35 out.print( (newEmail) );
|
|
36 out.print( "\r\n\r\nPlease click on the link below if you want to confirm this change:\r\n" );
|
|
37 out.print( (url) );
|
|
38 out.print( "\r\n\r\nIf you didn't request this email or have no idea why you received it, please ignore it.\r\n\r\nRegards,\r\nThe Nabble Team\r\n" );
|
|
39
|
|
40 out.flush();
|
|
41 String text = content.toString();
|
|
42
|
|
43 content.getBuffer().setLength(0);
|
|
44 // aol part
|
|
45
|
|
46 out.print( "\r\nDear " );
|
|
47 out.print( (username) );
|
|
48 out.print( ",\r\n\r\nYou or the administrator of \"" );
|
|
49 out.print( (site.getRootNode().getSubject()) );
|
|
50 out.print( "\" wants to change the email address of your user account.\r\nUsername: " );
|
|
51 out.print( (username) );
|
|
52 out.print( "\r\nOld email address: " );
|
|
53 out.print( (oldEmail) );
|
|
54 out.print( "\r\nNew email address: " );
|
|
55 out.print( (newEmail) );
|
|
56 out.print( "\r\n\r\nPlease click on the link below if you want to confirm this change:\r\n<a href=\"" );
|
|
57 out.print( (url) );
|
|
58 out.print( "\">" );
|
|
59 out.print( (url) );
|
|
60 out.print( "</a>\r\n\r\nIf you didn't request this email or have no idea why you received it, please ignore it.\r\n\r\nRegards,\r\nThe Nabble Team\r\n" );
|
|
61
|
|
62 out.flush();
|
|
63 String aol = content.toString();
|
|
64
|
|
65 out.close();
|
|
66 try {
|
|
67 Mail mail = MailHome.newMail();
|
|
68 mail.setFrom( new MailAddress(ModelHome.noReply) );
|
|
69 mail.setTo( new MailAddress(newEmail) );
|
|
70 mail.setSubject( "Email Change" );
|
|
71 mail.setContent( new AlternativeMultipartContent(new Content[]{
|
|
72 new PlainTextContent(text),
|
|
73 new TextContent("x-aol",aol),
|
|
74 }) );
|
|
75 ModelHome.send(mail);
|
|
76 } catch(MailException e) {
|
|
77 throw new RuntimeException(e);
|
|
78 }
|
|
79 }
|
|
80
|
|
81 }
|
|
82
|