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

Public Member Functions

 MailMessagePool ()
 
void setEncoding (String encoding)
 
MailMessage addToPoolTemplate (String from, String to, String cc, String subject, String message, String template, String name, String login)
 
MailMessage addToPoolTemplate (String from, String to, String cc, String subject, String message, String template, String name, String login, Map args)
 
MailMessage addToPool (String from, String to, String cc, String subject, String message)
 
MailMessage addToPool (MailMessage mail) throws EmailException
 
void sendPool ()
 
void sendPool (Consumer onFinish)
 
- Public Member Functions inherited from org.turro.elephant.impl.abstracts.AbstractImplementation
 AbstractImplementation ()
 
void setElement (IElement element)
 
void setConstructor (IConstructor constructor)
 
void setConfiguration (Element configuration)
 
KeyValueMap getAttributes ()
 
Long getLongAttribute (String key)
 

Additional Inherited Members

- Protected Attributes inherited from org.turro.elephant.impl.abstracts.AbstractImplementation
IElement iel
 
IConstructor constructor
 
Element configuration
 
Map attributes
 

Detailed Description

Constructor & Destructor Documentation

◆ MailMessagePool()

org.turro.mail.impl.MailMessagePool.MailMessagePool ( )

Creates a new instance of MailMessagePool

Definition at line 45 of file elephant/src/main/java/org/turro/mail/impl/MailMessagePool.java.

45  {
46  }

Member Function Documentation

◆ addToPool() [1/2]

MailMessage org.turro.mail.impl.MailMessagePool.addToPool ( MailMessage  mail) throws EmailException

Definition at line 106 of file elephant/src/main/java/org/turro/mail/impl/MailMessagePool.java.

106  {
107  try {
108  mail.addHeader("X-Mailer", "Elephant Mail System");
109  mail.setSentDate(date);
110  mail.setHostName((String) getAttributes().get("mailhost"));
111  mail.setPort((String) getAttributes().get("port"));
112  mail.setTls((String) getAttributes().get("tls"));
113  mail.setSsl((String) getAttributes().get("ssl"));
114  mail.setUser((String) getAttributes().get("user"));
115  String password = (String) getAttributes().get("password");
116  if(password == null) {
117  password = ElephantContext.decrypt((String) getAttributes().get("cryptpass"));
118  }
119  mail.setPassword(password);
120  mail.setFromIfNull((String) getAttributes().get("from"));
121  mail.setSubject(cleanSubject(mail.getSubject()));
122 
123  pool.add(mail);
124 
125  Logger.getLogger(MailMessagePool.class.getName()).log(Level.INFO, "Added mail from {0} to {1}. Subject: {2}",
126  new Object[]{mail.getEmail().getFromAddress().getAddress(),
127  InternetAddress.toString((InternetAddress[]) mail.getEmail().getToAddresses().toArray(new InternetAddress[0])), mail.getSubject()});
128 
129  return mail;
130  } catch(Exception ex) {
131  Logger.getLogger(MailMessagePool.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
132  }
133  return null;
134  }
Here is the call graph for this function:

◆ addToPool() [2/2]

MailMessage org.turro.mail.impl.MailMessagePool.addToPool ( String  from,
String  to,
String  cc,
String  subject,
String  message 
)

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

85  {
86  try {
87  if (to == null) {
88  return null;
89  }
90  MailMessage mail = new MailMessage();
91  mail.setCharset(encoding);
92  mail.setFrom(from == null ? (String) getAttributes().get("from") : from);
93  mail.addTo(to);
94  if (cc != null) {
95  mail.addCc(cc);
96  }
97  mail.setSubject(subject);
98  mail.setMessage(message);
99  return addToPool(mail);
100  } catch (EmailException ex) {
101  Logger.getLogger(MailMessagePool.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
102  }
103  return null;
104  }
MailMessage addToPool(String from, String to, String cc, String subject, String message)

◆ addToPoolTemplate() [1/2]

MailMessage org.turro.mail.impl.MailMessagePool.addToPoolTemplate ( String  from,
String  to,
String  cc,
String  subject,
String  message,
String  template,
String  name,
String  login 
)

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

53  {
54  return addToPoolTemplate(from, to, cc, subject, message, template, name, login, null);
55  }
MailMessage addToPoolTemplate(String from, String to, String cc, String subject, String message, String template, String name, String login)

◆ addToPoolTemplate() [2/2]

MailMessage org.turro.mail.impl.MailMessagePool.addToPoolTemplate ( String  from,
String  to,
String  cc,
String  subject,
String  message,
String  template,
String  name,
String  login,
Map  args 
)

Definition at line 57 of file elephant/src/main/java/org/turro/mail/impl/MailMessagePool.java.

58  {
59  try {
60  if (to == null) {
61  return null;
62  }
63  MailMessageTemplate mmt = new MailMessageTemplate();
64  mmt.setCharset(encoding);
65  mmt.setSubject(subject);
66  mmt.setFrom(from == null ? (String) getAttributes().get("from") : from);
67  mmt.addTo(to);
68  if (cc != null) {
69  mmt.addCc(cc);
70  }
71  ElephantMarker em = new ElephantMarker(constructor, true);
72  em.put("email", to);
73  em.put("body", message);
74  if(args != null) {
75  em.putAll(args);
76  }
77  mmt.setMessage(em, template, to, name);
78  return addToPool(mmt);
79  } catch (EmailException ex) {
80  Logger.getLogger(MailMessagePool.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
81  }
82  return null;
83  }

◆ sendPool() [1/2]

void org.turro.mail.impl.MailMessagePool.sendPool ( )

◆ sendPool() [2/2]

void org.turro.mail.impl.MailMessagePool.sendPool ( Consumer  onFinish)

Definition at line 140 of file elephant/src/main/java/org/turro/mail/impl/MailMessagePool.java.

140  {
141  //MailQueueConsumer.getInstance().addToQueue(pool, onFinish);
142  //new MailMessagePoolSender(pool).send(onFinish);
143  pool.clear();
144  }

◆ setEncoding()

void org.turro.mail.impl.MailMessagePool.setEncoding ( String  encoding)

Definition at line 48 of file elephant/src/main/java/org/turro/mail/impl/MailMessagePool.java.

48  {
49  this.encoding = encoding;
50  }

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