19 package org.turro.mail.sender;
22 import org.apache.commons.mail.EmailException;
23 import org.turro.action.MailAttachment;
24 import org.turro.action.queue.NotificationCategory;
25 import org.turro.annotation.ElephantPlugin;
26 import org.turro.assistant.Assistant;
27 import org.turro.elephant.context.Application;
28 import org.turro.elephant.context.ElephantContext;
29 import org.turro.elephant.context.IConstructor;
30 import org.turro.elephant.impl.util.StringParser;
31 import org.turro.mail.message.MailMessage;
32 import org.turro.mail.message.MailMessageTemplate;
33 import org.turro.mail.pool.MailMessagePool;
34 import org.turro.mail.provider.MailProviders;
35 import org.turro.marker.ElephantMarker;
36 import org.turro.string.Strings;
42 @ElephantPlugin(label =
"pool")
49 if(category !=
null && !assistants.isEmpty()) {
54 StringParser.
toHTML((Strings.isBlank(assistants.getSubject()) ?
"" : assistants.getSubject() +
"\n\n")) +
57 for(File file : attachments) {
58 mmt.
attach(file.getAbsolutePath(), file.getName(), file.getName());
61 mmt.
attach(ma.attachment.getAbsolutePath(), ma.name, ma.name);
72 if(category !=
null && !assistants.isEmpty()) {
77 if(!Strings.isBlank(root)) mmt.
setRoot(root);
79 mmt.
addTo(a.email, a.name);
81 mmt.
setFrom(from.getEmail(), from.getName());
84 if(entity !=
null) em.
put(
"entity", entity);
85 if(a.contact !=
null) em.
put(
"contact", a.contact);
86 em.
put(
"email", a.email);
87 em.
put(
"name", a.name);
88 em.
putAll(getAttributes());
90 for(File file : attachments) {
91 mmt.
attach(file.getAbsolutePath(), file.getName(), file.getName());
94 mmt.
attach(ma.attachment.getAbsolutePath(), ma.name, ma.name);
IConstructor getConstructor()
static Application getApplication()
static String getSiteName()
static String toHTML(String value)
void setMessage(ElephantMarker marker, IContact contact)
static MailMessageTemplate of(MailProvider provider)
void setRoot(String root)
void attach(String path, String description, String name)
Email setFrom(String email, String name)
Email addTo(String email, String name)
void setSubject(String subject)
MailMessage addToPool(String from, String to, String cc, String subject, String message)
MailProvider getProvider()
MailMessage addToPoolTemplate(String from, String to, String cc, String subject, String message, String template, String name, String login)
static MailProviders instance()
static final String GENERIC
MailMessagePool getPool(IConstructor constructor, String name)
void doSendTemplate(NotificationCategory category, Object entity, String template, String subject)
void doSend(NotificationCategory category, String subject, String message)
Object put(Object key, Object value)