19 package org.turro.mail.sender;
21 import java.util.logging.Level;
22 import java.util.logging.Logger;
23 import org.apache.commons.mail.EmailException;
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.elephant.security.IUser;
32 import org.turro.mail.message.MailMessageTemplate;
33 import org.turro.mail.provider.MailProviders;
34 import org.turro.mail.queue.QueueManager;
35 import org.turro.marker.ElephantMarker;
36 import org.turro.string.Strings;
42 @ElephantPlugin(label =
"queue")
49 if(category !=
null && !assistants.isEmpty()) {
54 StringParser.
toHTML((Strings.isBlank(assistants.getSubject()) ?
"" : assistants.getSubject() +
"\n\n")) +
59 if(onFinish !=
null) {
61 onFinish.accept(message);
62 }
catch (Exception ex) {
73 if(category !=
null && !assistants.isEmpty()) {
79 if(!Strings.isBlank(root)) mmt.
setRoot(root);
83 em.
put(
"entity", entity);
84 em.
put(
"contact", a.contact);
86 em.
putAll(getAttributes());
88 qm.
addToQueue(category, a.contact, mmt, reason, pool);
91 if(onFinish !=
null) {
93 onFinish.accept(
null);
94 }
catch (Exception ex) {
IConstructor getConstructor()
static Application getApplication()
static String logMsg(String msg)
static String toHTML(String value)
void setMessage(ElephantMarker marker, IContact contact)
static MailMessageTemplate of(MailProvider provider)
void setRoot(String root)
Email addTo(String email, String name)
void setSubject(String subject)
MailProvider getProvider(String name)
static MailProviders instance()
static final String GENERIC
MailItem addToQueue(NotificationCategory category, IContact contact, MailMessage mmt, String reason, String poolName)
boolean contactMayWant(IContact contact, String idCategory)
void doSend(NotificationCategory category, String subject, String message)
void doSendTemplate(NotificationCategory category, Object entity, String template, String subject)
Object put(Object key, Object value)
static final String CONNECTOR_EMAIL