|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jalios.jstore.BasicStorable com.jalios.jcms.Data com.jalios.jcms.Publication com.jalios.jcms.Content com.jalios.jcms.mail.MailMessage
public class MailMessage
Class used to build and send a mail message.
Example :
MailMessage msg = new MailMessage("myplugin.log-mail"); msg.setTo(channel.getDefaultAdmin()); msg.setSubject("[" + channel.getName() + "] Daily log"); msg.setContentText("Daily log attached"); msg.addFile(new File(channel.getRealPath("WEB-INF/data/logs/jcms.log"))); msg.send(); logger.info("Log mail sent in " + Util.formatDuration(msg.getDuration()));
MailMessage msg = new MailMessage("starwarsplugin.war-mail-alert"); msg.setFrom("Darth Vader <dv@deathstar.com>"); msg.setTo("Son <luke@alliance.com>"); msg.setBcc("Palpatine <palpatine@deathstar.com>"); for (Member sithMember : sithGroup.getMemberSet()) { msg.addCc(sithMember); } msg.setSubject("I am your father"); msg.setContentText("The Force is with you, young Skywalker. But you are not a Jedi yet."); msg.setContentHtml("The <strong>Force</strong> is with you, young Skywalker. But you are not a Jedi yet."); msg.send();
Nested Class Summary | |
---|---|
static class |
MailMessage.Part
Convenient recursive structure to wrap javax.mail.Message Part |
static class |
MailMessage.SentDateComparator<T extends MailMessage>
Compares two MailMessage using their SentDate in descending order (newest date first). |
Nested classes/interfaces inherited from class com.jalios.jcms.Data |
---|
Data.AuthorSelector, Data.CdateSelector, Data.DataNameComparator<T extends Data>, Data.DeletableSelector, Data.ImportSelector, Data.MdateSelector, Data.OpAuthorComparator<T extends Data>, Data.RowIdComparator<T extends Data>, Data.StrongLockSelector |
Nested classes/interfaces inherited from class com.jalios.jstore.BasicStorable |
---|
BasicStorable.CdateComparator<T extends Storable>, BasicStorable.IdComparator<T extends Storable>, BasicStorable.MdateComparator<T extends Storable> |
Field Summary | |
---|---|
protected static int |
ASCII_WIDTH
|
static String |
DB_MESSAGE_ACCOUNT
|
static String |
DB_MESSAGE_BCC
|
static String |
DB_MESSAGE_CC
|
static String |
DB_MESSAGE_FROM
|
static String |
DB_MESSAGE_ID
|
static String |
DB_MESSAGE_INREPLYTO
|
static String |
DB_MESSAGE_REFERENCES
|
static String |
DB_MESSAGE_REPLYTO
|
static String |
DB_MESSAGE_SUBJECT
|
static String |
DB_MESSAGE_THREAD
|
static String |
DB_MESSAGE_TO
|
protected long |
duration
|
protected Map<File,String> |
fileMap
|
protected Map<String,Object> |
headers
|
protected javax.mail.Message |
message
|
protected Collection<MailMessage.Part> |
multiparts
|
static String |
REVISION
|
static String |
SEP
|
Fields inherited from class com.jalios.jcms.Data |
---|
author, authorDBID, channel, DISPLAY_URL_EXTRA_INFO, extension, extraDataMap, extraDBDataMapToSaveOnOp, importMap, opAuthor, opDelegate |
Fields inherited from class com.jalios.jstore.BasicStorable |
---|
cdate, ddate, id, mdate, store |
Fields inherited from interface com.jalios.jcms.mashup.ImportConstants |
---|
IMPORT_ALARM_MGR, IMPORT_AUTHOR_PROP, IMPORT_CATEGORY_DEFAULT, IMPORT_DC_ATTR, IMPORT_DC_STEP, IMPORT_DIR, IMPORT_ENABLED, IMPORT_JDOM_ELEMENT, IMPORT_LOG_FILE, IMPORT_LOG_MAX, IMPORT_OPTIONS, IMPORT_OPTIONS_DC_CONTEXT, IMPORT_ROOT_PROP, IMPORT_SOURCE_FILE, IMPORT_SOURCE_PREFIX_PROP, IMPORT_SOURCES_DIR, IMPORT_STEP_CLEAN, IMPORT_STEP_IMPORT, IMPORT_STEP_UPDATE_REF, IMPORT_WS_PROP |
Fields inherited from interface com.jalios.jcms.mashup.MashupConstants |
---|
DATA_TAG, DATASET_TAG, FIELD_CLASS, FIELD_ENTRY, FIELD_ITEM, FIELD_KEY, FIELD_NAME, FIELD_TAG, FIELD_VALUE, FILE_FIELD, FILE_ID, FILE_MTIME, FILE_SIZE, FILE_TAG, FILE_TICKET, FILESET_TAG, RELATED_TAG |
Fields inherited from interface com.jalios.util.JaliosConstants |
---|
CRLF, MILLIS_IN_ONE_DAY, MILLIS_IN_ONE_HOUR, MILLIS_IN_ONE_MINUTE, MILLIS_IN_ONE_MONTH, MILLIS_IN_ONE_SECOND, MILLIS_IN_ONE_WEEK, MILLIS_IN_ONE_YEAR |
Constructor Summary | |
---|---|
MailMessage()
|
|
MailMessage(MailMessage other)
|
|
MailMessage(javax.mail.Message msg)
|
|
MailMessage(String origin)
|
Method Summary | |
---|---|
MailMessage |
addAttachements(FileDocument v)
|
MailMessage |
addAttachements(Set<FileDocument> v)
|
MailMessage |
addBcc(Member v)
|
MailMessage |
addBcc(Set<Member> v)
|
MailMessage |
addBcc(String v)
|
MailMessage |
addCc(Member v)
|
MailMessage |
addCc(Set<Member> v)
|
MailMessage |
addCc(String v)
|
MailMessage |
addFile(File file)
Add a file to send with this MailMessage. |
MailMessage |
addFile(File file,
String id)
Add a file to send with this MailMessage. |
MailMessage |
addTo(Member v)
|
MailMessage |
addTo(Set<Member> v)
|
MailMessage |
addTo(String v)
|
protected javax.mail.Message |
buildOneMessageForAll()
Create one message to be sent to all recipients. |
protected javax.mail.Message[] |
buildOneMessageForEach()
Create one message one for each recipients. |
protected void |
fillMessageContent(javax.mail.Message message)
|
String |
getAccount()
|
protected Set<String> |
getAddressSet(javax.mail.Address[] ia)
Returns a Set of Address.toString() |
Set<FileDocument> |
getAttachements()
|
Set<FileDocument> |
getAttachements(boolean b)
|
Set<String> |
getBcc()
|
javax.mail.internet.InternetAddress[] |
getBccIA()
|
Set<Member> |
getBccMember()
|
Set<Member> |
getBccMember(boolean b)
|
Set<String> |
getCc()
|
javax.mail.internet.InternetAddress[] |
getCcIA()
|
Set<Member> |
getCcMember()
|
Set<Member> |
getCcMember(boolean b)
|
String |
getContentHtml()
|
String |
getContentText()
|
javax.mail.BodyPart[] |
getCustomBodyParts()
|
protected javax.activation.DataHandler |
getDataHandler(File file)
Compute the correct handler to manage this file |
long |
getDuration()
Retrieve the time the sending process took to execute. |
Map<File,String> |
getFileMap()
Retrieve the Map of File/id to send in this MailMessage. |
protected String |
getFirstAddress(javax.mail.Address[] ia)
Returns the first Address.toString() |
javax.mail.internet.InternetAddress |
getFirstFromIA()
Resolve "From" from all froms and Member's from |
protected javax.mail.internet.InternetAddress |
getFirstIA(String email,
Member mbr)
|
String |
getFrom()
|
javax.mail.internet.InternetAddress[] |
getFromIA()
|
Member |
getFromMember()
|
protected javax.mail.internet.InternetAddress[] |
getIAQuietly(Set<String> address,
Set<Member> addressMember)
Returns an array of InternetAddress joins of addresses and Member's addresses |
String |
getInReplyTo()
|
Collection<? extends MailMessage> |
getMailMessageReplies()
Returns a Collection of MailMessage replies of the current MailMessage |
Collection<? extends MailMessage> |
getMailMessageThread()
Returns a Collection of MailMessage, thread of the current discussion in ascending order (oldest date first). |
String |
getMatchingRecipient(Pattern pattern)
Returns the address matching the given pattern in all recipient and members |
String |
getMatchingRecipient(String address)
Returns the address matching (indexOf) the given address in all recipient and members |
String |
getMessageId()
|
String |
getOrigin()
|
int |
getPriority()
|
Date |
getReceivedDate()
|
Set<String> |
getRecipient()
|
Set<Member> |
getRecipientMember()
|
Set<String> |
getReferences()
|
String |
getReplyTo()
|
javax.mail.internet.InternetAddress[] |
getReplyToIA()
|
Member |
getReplyToMember()
|
boolean |
getSendAcknowledge()
Get whether acknowledge message should be sent at end of process. |
Member |
getSenderMember()
|
boolean |
getSendOneMailPerRecipient()
Get sending mode, one mail for all recipients (false), or one mail for each recipients (true). |
Date |
getSentDate()
|
Member |
getSingleRecipient()
Returns the single Member recipients of the message or null if there is multiple recipients |
String |
getSubject()
|
Map<String,Object> |
getTemporaryHeaders()
Returns a temporary Map of all mail's header. |
javax.mail.Message |
getTemporaryMessage()
Returns temporary javax.mail.Message store while fetching mail Message might be null. Message fields calls can throw Exception if MailBox is closed. |
Collection<MailMessage.Part> |
getTemporaryMultiparts()
Returns flatten collection of MailMessage.Part with decoded Files and Contents |
String |
getThread()
|
Set<String> |
getTo()
|
javax.mail.internet.InternetAddress[] |
getToIA()
|
Set<Member> |
getToMember()
|
Set<Member> |
getToMember(boolean b)
|
Collection<? extends TreeNode> |
getTreeChildren()
Returns a Collection of TreeNode children of the current node |
TreeNode |
getTreeParent()
Returns parent of the current node |
protected void |
performBeforeWrite(int op,
Member mbr,
Map context)
Called to perform some action before the write. |
void |
send()
Send this MailMessage. |
void |
send(HashMap<String,Object> ctxt)
Send this MailMessage. |
protected void |
sendAcknowledge(Collection<javax.mail.Message> successMessages,
Collection<javax.mail.Message> errorMessages)
|
void |
sendInThread()
Send this MailMessage in a seperate thread. |
void |
sendInThread(HashMap<String,Object> ctxt)
Send this MailMessage in a seperate thread. |
void |
setAccount(String v)
|
void |
setAttachements(Set<FileDocument> v)
|
MailMessage |
setBcc(Member v)
|
void |
setBcc(Set<String> v)
|
MailMessage |
setBcc(String v)
|
void |
setBccMember(Set<Member> v)
|
MailMessage |
setCc(Member v)
|
void |
setCc(Set<String> v)
|
MailMessage |
setCc(String v)
|
void |
setCcMember(Set<Member> v)
|
void |
setContentHtml(String v)
|
MailMessage |
setContentHtmlFromJsp(String jspPath,
Member loggedMember,
String language,
HashMap<Object,Object> requestAttribute,
HashMap<Object,Object> sessionAttribute)
Set the HTML text content of this MailMessage from the rendering of the specified jsp. |
void |
setContentText(String v)
|
MailMessage |
setContentTextFromJsp(String jspPath,
Member loggedMember,
String language,
HashMap<Object,Object> requestAttribute,
HashMap<Object,Object> sessionAttribute)
Set the plain text content of this MailMessage from the rendering of the specified jsp. |
void |
setCustomBodyParts(javax.mail.BodyPart[] v)
|
MailMessage |
setFrom(Member v)
|
void |
setFrom(String v)
|
void |
setFromMember(Member v)
|
void |
setInReplyTo(String v)
|
protected void |
setMessage(javax.mail.Message msg)
Set fields for the given Message and download attachements in temporary folder Caller should also set: Account setAccount() Author setAuthor() |
void |
setMessageId(String v)
|
void |
setOrigin(String origin)
|
void |
setPriority(int v)
|
void |
setReceivedDate(Date v)
|
void |
setReferences(Set<String> v)
|
MailMessage |
setReplyTo(Member v)
|
void |
setReplyTo(String v)
|
void |
setReplyToMember(Member v)
|
void |
setSendAcknowledge(boolean sendAcknowledge)
Set whether acknowledge message should be sent at end of process. |
void |
setSendOneMailPerRecipient(boolean sendOneMailPerRecipient)
Set sending mode, one mail for all recipients (false), or one mail for each recipients (true). |
void |
setSentDate(Date v)
|
void |
setSubject(String v)
|
void |
setThread(String v)
|
MailMessage |
setTo(Member v)
|
void |
setTo(Set<String> v)
|
MailMessage |
setTo(String v)
|
void |
setToMember(Set<Member> v)
|
Methods inherited from class com.jalios.jstore.BasicStorable |
---|
clearId, compareTo, equals, getAttribute, getAttributes, getCdate, getCdateComparator, getDdate, getId, getIdComparator, getMdate, getMdateComparator, getStore, getUrid, hasBeenUpdated, isStored, resolveAtt, resolveVal, setAttributes, setDdate, setId, setStore, toXml |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String REVISION
public static final String SEP
public static final String DB_MESSAGE_ID
public static final String DB_MESSAGE_FROM
public static final String DB_MESSAGE_TO
public static final String DB_MESSAGE_CC
public static final String DB_MESSAGE_BCC
public static final String DB_MESSAGE_REPLYTO
public static final String DB_MESSAGE_INREPLYTO
public static final String DB_MESSAGE_REFERENCES
public static final String DB_MESSAGE_SUBJECT
public static final String DB_MESSAGE_ACCOUNT
public static final String DB_MESSAGE_THREAD
protected transient javax.mail.Message message
protected transient Map<String,Object> headers
protected transient Collection<MailMessage.Part> multiparts
protected transient Map<File,String> fileMap
protected transient long duration
protected static final int ASCII_WIDTH
Constructor Detail |
---|
public MailMessage()
public MailMessage(MailMessage other)
public MailMessage(javax.mail.Message msg) throws IOException, javax.mail.MessagingException
IOException
javax.mail.MessagingException
public MailMessage(String origin)
Method Detail |
---|
public String getSubject()
public String getOrigin()
public String getFrom()
public Set<String> getTo()
public Set<String> getCc()
public Set<String> getBcc()
public String getReplyTo()
public Member getFromMember()
public Set<Member> getToMember()
public Set<Member> getToMember(boolean b)
public Set<Member> getCcMember()
public Set<Member> getCcMember(boolean b)
public Set<Member> getBccMember()
public Set<Member> getBccMember(boolean b)
public Member getReplyToMember()
public Member getSenderMember()
public Set<FileDocument> getAttachements()
public Set<FileDocument> getAttachements(boolean b)
public String getContentText()
public String getContentHtml()
public String getAccount()
public int getPriority()
public Date getSentDate()
public Date getReceivedDate()
public String getMessageId()
public String getInReplyTo()
public Set<String> getReferences()
public String getThread()
public javax.mail.BodyPart[] getCustomBodyParts()
public void setSubject(String v)
public void setOrigin(String origin)
public void setFrom(String v)
public void setTo(Set<String> v)
public void setCc(Set<String> v)
public void setBcc(Set<String> v)
public void setReplyTo(String v)
public void setFromMember(Member v)
public void setToMember(Set<Member> v)
public void setCcMember(Set<Member> v)
public void setBccMember(Set<Member> v)
public void setReplyToMember(Member v)
public void setAttachements(Set<FileDocument> v)
public void setContentText(String v)
public void setContentHtml(String v)
public void setAccount(String v)
public void setPriority(int v)
public void setSentDate(Date v)
public void setReceivedDate(Date v)
public void setMessageId(String v)
public void setInReplyTo(String v)
public void setReferences(Set<String> v)
public void setThread(String v)
public void setCustomBodyParts(javax.mail.BodyPart[] v)
public void setSendOneMailPerRecipient(boolean sendOneMailPerRecipient)
Default is false, ie send one mail for all.
sendOneMailPerRecipient
- set to true to send one mail to each recipient, false to send one mail for all.public void setSendAcknowledge(boolean sendAcknowledge)
sendAcknowledge
- the acknowledge messagepublic javax.mail.internet.InternetAddress[] getFromIA()
public javax.mail.internet.InternetAddress[] getToIA()
public javax.mail.internet.InternetAddress[] getCcIA()
public javax.mail.internet.InternetAddress[] getBccIA()
public javax.mail.internet.InternetAddress[] getReplyToIA()
public MailMessage setTo(String v)
public MailMessage setCc(String v)
public MailMessage setBcc(String v)
public MailMessage setFrom(Member v)
public MailMessage setTo(Member v)
public MailMessage setCc(Member v)
public MailMessage setBcc(Member v)
public MailMessage setReplyTo(Member v)
public MailMessage addTo(String v)
public MailMessage addCc(String v)
public MailMessage addBcc(String v)
public MailMessage addTo(Member v)
public MailMessage addCc(Member v)
public MailMessage addBcc(Member v)
public MailMessage addTo(Set<Member> v)
public MailMessage addCc(Set<Member> v)
public MailMessage addBcc(Set<Member> v)
public MailMessage addAttachements(FileDocument v)
public MailMessage addAttachements(Set<FileDocument> v)
public Set<String> getRecipient()
public Set<Member> getRecipientMember()
public boolean getSendOneMailPerRecipient()
Default is false, ie send one mail for all.
public boolean getSendAcknowledge()
public String getMatchingRecipient(String address)
address
- to match
public String getMatchingRecipient(Pattern pattern)
pattern
- to match
public javax.mail.internet.InternetAddress getFirstFromIA()
protected javax.mail.internet.InternetAddress getFirstIA(String email, Member mbr)
public Member getSingleRecipient()
protected javax.mail.internet.InternetAddress[] getIAQuietly(Set<String> address, Set<Member> addressMember)
address
- Set of email addressaddressMember
- Set of member
protected Set<String> getAddressSet(javax.mail.Address[] ia)
ia
- an array of Address
protected String getFirstAddress(javax.mail.Address[] ia)
ia
- an array of Address
public MailMessage setContentHtmlFromJsp(String jspPath, Member loggedMember, String language, HashMap<Object,Object> requestAttribute, HashMap<Object,Object> sessionAttribute)
jspPath
- a jsp path relative to the webapp root e.g "/custom/jcms/doNotificationText.jsp"
loggedMember
- the Member that will be set as the logged member when invoking jsplanguage
- the language that will be set when invoking jsprequestAttribute
- a HashMap of request attribute available to the jsp executionsessionAttribute
- a HashMap of session attribute available to the jsp execution
public MailMessage setContentTextFromJsp(String jspPath, Member loggedMember, String language, HashMap<Object,Object> requestAttribute, HashMap<Object,Object> sessionAttribute)
jspPath
- a jsp path relative to the webapp root e.g "/custom/jcms/doNotificationText.jsp"
loggedMember
- the Member that will be set as the logged member when invoking jsplanguage
- the language that will be set when invoking jsprequestAttribute
- a HashMap of request attribute available to the jsp executionsessionAttribute
- a HashMap of session attribute available to the jsp execution
public javax.mail.Message getTemporaryMessage()
public Collection<MailMessage.Part> getTemporaryMultiparts()
public Map<String,Object> getTemporaryHeaders()
protected void setMessage(javax.mail.Message msg) throws javax.mail.MessagingException, IOException
msg
- the message
javax.mail.MessagingException
- if an error occurs
IOException
- if an error occursprotected void performBeforeWrite(int op, Member mbr, Map context)
Data
performBeforeWrite
in class Publication
op
- the operation (OP_CREATE, OP_UPDATE, ...)mbr
- the member which requests the write operationcontext
- a map which contains context parameters (may be null)public Map<File,String> getFileMap()
public MailMessage addFile(File file)
file
- a File to send.
public MailMessage addFile(File file, String id)
file
- a File to send.id
- an optionnal identifier for this file
protected javax.mail.Message buildOneMessageForAll() throws javax.mail.MessagingException
javax.mail.MessagingException
- if an error occursprotected javax.mail.Message[] buildOneMessageForEach() throws javax.mail.MessagingException
javax.mail.MessagingException
- if an error occursprotected void fillMessageContent(javax.mail.Message message) throws javax.mail.MessagingException
javax.mail.MessagingException
protected javax.activation.DataHandler getDataHandler(File file) throws javax.mail.MessagingException
file
- the File
to add
DataHandler
javax.mail.MessagingException
- if any exception occurspublic long getDuration()
public void send() throws javax.mail.MessagingException
javax.mail.MessagingException
- if an error occurspublic void send(HashMap<String,Object> ctxt) throws javax.mail.MessagingException
ctxt
- an optionnal context used to store information for this mail sending
(context may be used by MailPolicyFilters in beforeSendMail and afterSensMail)
javax.mail.MessagingException
- if an error occurspublic void sendInThread()
public void sendInThread(HashMap<String,Object> ctxt)
ctxt
- an optionnal context used to store information for this mail sending
(context may be used by MailPolicyFilters in beforeSendMail and afterSensMail)protected void sendAcknowledge(Collection<javax.mail.Message> successMessages, Collection<javax.mail.Message> errorMessages)
public TreeNode getTreeParent()
TreeNode
getTreeParent
in interface TreeNode
getTreeParent
in class Publication
TreeNode.getTreeParent()
public Collection<? extends TreeNode> getTreeChildren()
TreeNode
getTreeChildren
in interface TreeNode
getTreeChildren
in class Publication
TreeNode.getTreeChildren()
public Collection<? extends MailMessage> getMailMessageReplies()
public Collection<? extends MailMessage> getMailMessageThread()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |