BrightSide Workbench Full Report + Source Code
org.turro.mail.impl.MailMessage Class Reference
Inheritance diagram for org.turro.mail.impl.MailMessage:

Public Member Functions

 MailMessage ()
 
 MailMessage (String hostName, String user, String password)
 
HtmlEmail getEmail ()
 
void setHostName (String hostName)
 
void setPassword (String password)
 
void setUser (String user)
 
String getMessage ()
 
void setMessage (String message)
 
String getSubject ()
 
void setSubject (String subject)
 
String getPort ()
 
void setPort (String port)
 
String getTls ()
 
void setTls (String tls)
 
String getSsl ()
 
void setSsl (String ssl)
 
void attachRelative (String path, String description, String name)
 
void attach (String path, String description, String name)
 
void attachExternal (URL url, String description, String name)
 
void embedRelative (String name, String path)
 
void embed (String name, File file)
 
void embedExternal (String name, String url) throws MalformedURLException
 
void send () throws EmailException, MalformedURLException, NamingException
 
Email setFromIfNull (String email) throws EmailException
 
Date getSentDate ()
 
void setSentDate (Date date)
 
Email setFrom (String email, String name) throws EmailException
 
Email setFrom (String email) throws EmailException
 
Email addTo (String email, String name) throws EmailException
 
Email addTo (String email) throws EmailException
 
Email addReplyTo (String email, String name) throws EmailException
 
Email addReplyTo (String email) throws EmailException
 
void addHeader (String name, String value)
 
Email addCc (String email, String name) throws EmailException
 
Email addCc (String email) throws EmailException
 
Email addBcc (String email, String name) throws EmailException
 
Email addBcc (String email) throws EmailException
 
void setCharset (String newCharset)
 

Detailed Description

Constructor & Destructor Documentation

◆ MailMessage() [1/2]

org.turro.mail.impl.MailMessage.MailMessage ( )

Definition at line 52 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

52  {
53  }

◆ MailMessage() [2/2]

org.turro.mail.impl.MailMessage.MailMessage ( String  hostName,
String  user,
String  password 
)

Definition at line 55 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

55  {
56  this.hostName = hostName;
57  this.user = user;
58  this.password = password;
59  }

Member Function Documentation

◆ addBcc() [1/2]

Email org.turro.mail.impl.MailMessage.addBcc ( String  email) throws EmailException

Definition at line 275 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

275  {
276  return this.email.addBcc(email);
277  }

◆ addBcc() [2/2]

Email org.turro.mail.impl.MailMessage.addBcc ( String  email,
String  name 
) throws EmailException

Definition at line 271 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

271  {
272  return this.email.addBcc(email, name);
273  }

◆ addCc() [1/2]

Email org.turro.mail.impl.MailMessage.addCc ( String  email) throws EmailException

Definition at line 267 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

267  {
268  return this.email.addCc(email);
269  }

◆ addCc() [2/2]

Email org.turro.mail.impl.MailMessage.addCc ( String  email,
String  name 
) throws EmailException

Definition at line 263 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

263  {
264  return this.email.addCc(email, name);
265  }

◆ addHeader()

void org.turro.mail.impl.MailMessage.addHeader ( String  name,
String  value 
)

Definition at line 259 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

259  {
260  email.addHeader(name, value);
261  }
Here is the caller graph for this function:

◆ addReplyTo() [1/2]

Email org.turro.mail.impl.MailMessage.addReplyTo ( String  email) throws EmailException

Definition at line 255 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

255  {
256  return this.email.addReplyTo(email);
257  }

◆ addReplyTo() [2/2]

Email org.turro.mail.impl.MailMessage.addReplyTo ( String  email,
String  name 
) throws EmailException

Definition at line 251 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

251  {
252  return this.email.addReplyTo(email, name);
253  }

◆ addTo() [1/2]

Email org.turro.mail.impl.MailMessage.addTo ( String  email) throws EmailException

Definition at line 246 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

246  {
247  if(Strings.isBlank(email)) return null;
248  return this.email.addTo(email);
249  }

◆ addTo() [2/2]

Email org.turro.mail.impl.MailMessage.addTo ( String  email,
String  name 
) throws EmailException

Definition at line 241 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

241  {
242  if(Strings.isBlank(email)) return null;
243  return this.email.addTo(email, name);
244  }

◆ attach()

void org.turro.mail.impl.MailMessage.attach ( String  path,
String  description,
String  name 
)

Definition at line 126 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

126  {
127  EmailAttachment attachment = new EmailAttachment();
128  attachment.setPath(path);
129  attachment.setDisposition(EmailAttachment.ATTACHMENT);
130  attachment.setDescription(description == null ? "" : description);
131  attachment.setName(name == null ? "" : name);
132  attachments.add(attachment);
133  }

◆ attachExternal()

void org.turro.mail.impl.MailMessage.attachExternal ( URL  url,
String  description,
String  name 
)

Definition at line 135 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

135  {
136  EmailAttachment attachment = new EmailAttachment();
137  attachment.setURL(url);
138  attachment.setDisposition(EmailAttachment.ATTACHMENT);
139  attachment.setDescription(description == null ? "" : description);
140  attachment.setName(name == null ? "" : name);
141  attachments.add(attachment);
142  }

◆ attachRelative()

void org.turro.mail.impl.MailMessage.attachRelative ( String  path,
String  description,
String  name 
)

Definition at line 117 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

117  {
118  EmailAttachment attachment = new EmailAttachment();
119  attachment.setPath(ElephantContext.getRealPath(path));
120  attachment.setDisposition(EmailAttachment.ATTACHMENT);
121  attachment.setDescription(description == null ? "" : description);
122  attachment.setName(name == null ? "" : name);
123  attachments.add(attachment);
124  }
Here is the call graph for this function:

◆ embed()

void org.turro.mail.impl.MailMessage.embed ( String  name,
File  file 
)

Definition at line 148 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

148  {
149  imageMap.put(name, file);
150  }
Here is the caller graph for this function:

◆ embedExternal()

void org.turro.mail.impl.MailMessage.embedExternal ( String  name,
String  url 
) throws MalformedURLException

Definition at line 152 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

152  {
153  imageURLMap.put(name, new URL(url));
154  }

◆ embedRelative()

void org.turro.mail.impl.MailMessage.embedRelative ( String  name,
String  path 
)

Definition at line 144 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

144  {
145  embed(name, new File(ElephantContext.getRealPath(path)));
146  }
Here is the call graph for this function:

◆ getEmail()

HtmlEmail org.turro.mail.impl.MailMessage.getEmail ( )

Definition at line 61 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

61  {
62  return email;
63  }

◆ getMessage()

String org.turro.mail.impl.MailMessage.getMessage ( )

Definition at line 77 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

77  {
78  return message;
79  }

◆ getPort()

String org.turro.mail.impl.MailMessage.getPort ( )

Definition at line 93 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

93  {
94  return port;
95  }

◆ getSentDate()

Date org.turro.mail.impl.MailMessage.getSentDate ( )

Definition at line 218 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

218  {
219  return email.getSentDate();
220  }

◆ getSsl()

String org.turro.mail.impl.MailMessage.getSsl ( )

Definition at line 109 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

109  {
110  return ssl;
111  }

◆ getSubject()

String org.turro.mail.impl.MailMessage.getSubject ( )

Definition at line 85 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

85  {
86  return subject;
87  }

◆ getTls()

String org.turro.mail.impl.MailMessage.getTls ( )

Definition at line 101 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

101  {
102  return tls;
103  }

◆ send()

void org.turro.mail.impl.MailMessage.send ( ) throws EmailException, MalformedURLException, NamingException

Definition at line 156 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

156  {
157  email.setCharset(ElephantContext.getEncoding());
158  if (hostName.startsWith("java:")) {
159  email.setMailSessionFromJNDI(hostName);
160  } else {
161  email.setHostName(hostName);
162  }
163  if(StringNumber.toInteger(port) != null) {
164  email.setSmtpPort(StringNumber.toInteger(port));
165  }
166  if(StringNumber.toBoolean(ssl)) {
167  email.setSSLOnConnect(true);
168  if(StringNumber.toInteger(port) != null) {
169  email.setSslSmtpPort(port);
170  }
171  }
172  if(StringNumber.toBoolean(tls)) {
173  email.setStartTLSEnabled(true);
174  }
175  if(user != null && password != null) {
176  email.setAuthentication(user, password);
177  }
178 
179  for(String n : imageMap.keySet()) {
180  String cid = email.embed(imageMap.get(n), n);
181  message = message.replaceAll("image\\(" + n + "\\)", "<img src=\"cid:" + cid + "\"/>");
182  }
183 
184  for(String n : imageURLMap.keySet()) {
185  String cid = email.embed(imageURLMap.get(n), n);
186  message = message.replaceAll("imageURL\\(" + n + "\\)", "<img src=\"cid:" + cid + "\"/>");
187  }
188 
189  email.setSubject(subject);
190 
191  for(EmailAttachment ea : attachments) {
192  email.attach(ea);
193  }
194 
195  String serverBase = ElephantContext.getServerBase("http");
196  message = message.replaceAll("href=\\'(?![a-z]+:)(\\/?)\\/?([^\\']*)\\'", "href=\\'" + serverBase + "$1$2\\'")
197  .replaceAll("src=\\'(?![a-z]+:)(\\/?)\\/?([^\\']*)\\'", "src=\\'" + serverBase + "$1$2\\'")
198  .replaceAll("href=\\\"(?![a-z]+:)(\\/?)\\/?([^\\\"]*)\\\"", "href=\\\"" + serverBase + "$1$2\\\"")
199  .replaceAll("src=\\\"(?![a-z]+:)(\\/?)\\/?([^\\\"]*)\\\"", "src=\\\"" + serverBase + "$1$2\\\"");
200 
201  message = new MailFormat().inline(message);
202 
203  email.setHtmlMsg(message);
204  email.setTextMsg("NO HTML SUPPORTED");
205 
206  email.send();
207  }
Here is the call graph for this function:

◆ setCharset()

void org.turro.mail.impl.MailMessage.setCharset ( String  newCharset)

Definition at line 279 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

279  {
280  email.setCharset(newCharset);
281  }

◆ setFrom() [1/2]

Email org.turro.mail.impl.MailMessage.setFrom ( String  email) throws EmailException

Definition at line 230 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

230  {
231  if(email != null) {
232  if(email.contains("|")) {
233  String[] parts = email.split("\\|");
234  return this.email.setFrom(parts[0], parts[1]);
235  }
236  return this.email.setFrom(email);
237  }
238  return this.email;
239  }

◆ setFrom() [2/2]

Email org.turro.mail.impl.MailMessage.setFrom ( String  email,
String  name 
) throws EmailException

Definition at line 226 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

226  {
227  return this.email.setFrom(email, name);
228  }
Here is the caller graph for this function:

◆ setFromIfNull()

Email org.turro.mail.impl.MailMessage.setFromIfNull ( String  email) throws EmailException

Definition at line 209 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

209  {
210  if(this.email.getFromAddress() == null && !Strings.isBlank(email)) {
211  return setFrom(email);
212  }
213  return this.email;
214  }
Here is the call graph for this function:

◆ setHostName()

void org.turro.mail.impl.MailMessage.setHostName ( String  hostName)

Definition at line 65 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

65  {
66  this.hostName = hostName;
67  }

◆ setMessage()

void org.turro.mail.impl.MailMessage.setMessage ( String  message)

Definition at line 81 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

81  {
82  this.message = message;
83  }

◆ setPassword()

void org.turro.mail.impl.MailMessage.setPassword ( String  password)

Definition at line 69 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

69  {
70  this.password = password;
71  }

◆ setPort()

void org.turro.mail.impl.MailMessage.setPort ( String  port)

Definition at line 97 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

97  {
98  this.port = port;
99  }

◆ setSentDate()

void org.turro.mail.impl.MailMessage.setSentDate ( Date  date)

Definition at line 222 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

222  {
223  email.setSentDate(date);
224  }

◆ setSsl()

void org.turro.mail.impl.MailMessage.setSsl ( String  ssl)

Definition at line 113 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

113  {
114  this.ssl = ssl;
115  }

◆ setSubject()

void org.turro.mail.impl.MailMessage.setSubject ( String  subject)

Definition at line 89 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

89  {
90  this.subject = subject;
91  }

◆ setTls()

void org.turro.mail.impl.MailMessage.setTls ( String  tls)

Definition at line 105 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

105  {
106  this.tls = tls;
107  }

◆ setUser()

void org.turro.mail.impl.MailMessage.setUser ( String  user)

Definition at line 73 of file elephant/src/main/java/org/turro/mail/impl/MailMessage.java.

73  {
74  this.user = user;
75  }

The documentation for this class was generated from the following file: