public class MailManager
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ADD_IMAGES_AUTHKEY
Name of both JCMS property and context map attribute defining a MailMessage behavior.
|
static java.lang.String |
REVISION |
static java.lang.String |
SEND_WITH_SITE_EMAIL
Name of both JCMS property and context map attribute defining a MailMessage behavior.
|
Modifier and Type | Method and Description |
---|---|
static void |
addAuthKeyToImagesSrc(MailMessage msg,
java.util.HashMap<java.lang.String,java.lang.Object> ctxt)
Rewrite the HTML content of the specified MailMessage to add an authentication key to all images URL.
|
static java.lang.String |
addAuthKeyToImagesSrc(java.lang.String content,
Member mbr)
Add an authentication key to all images URL in the specified HTML content.
|
static java.lang.String |
buildContentFromJsp(java.lang.String jspPath,
Member loggedMember,
java.lang.String language,
java.util.HashMap<java.lang.Object,java.lang.Object> requestAttributeMap,
java.util.HashMap<java.lang.Object,java.lang.Object> sessionAttributeMap)
Builds a mail content from a given jsp
|
MailMessage |
createDBMailMessage(javax.mail.Message msg,
MailAccount account)
Build a DBMessage from a Message and save in into the DB
|
MailMessage |
getDBMailMessage(javax.mail.Message msg)
Returns the DBMailMessage for the given Message
|
MailMessage |
getDBMailMessage(java.lang.String msgid)
Returns the DBMailMessage for the given Message Id
|
int |
getDBMailMessageCount()
Returns the count of DBMailMessage
|
int |
getDBMailMessageCount(java.lang.String account)
Returns the count of DBMailMessage for given account
|
java.util.Collection<? extends MailMessage> |
getDBMailMessageReplies(java.lang.String msgid)
Returns the DBMailMessage for the given Message Id
|
java.util.Set<java.lang.Object> |
getDBMailMessageSet(java.lang.String[] ids)
Returns a Collection of MailMessage or Message-ID (if not found)
|
java.util.Collection<? extends MailMessage> |
getDBMailMessageThread(java.lang.String thread) |
static java.util.Set<javax.mail.internet.InternetAddress> |
getIAFromMemberSet(java.util.Set<Member> mbrSet)
Returns a Set of InternetAddress build from a Set of Members
|
static java.lang.String |
getIncomingAddress(java.lang.String localpart,
Member mbr,
java.lang.String label)
Returns JCMS incoming email for the given Member
|
static MailManager |
getInstance() |
static java.util.TreeSet<java.lang.String> |
getInvalidEmailSet(java.util.Set<java.lang.String> mailSet,
java.util.Set<Member> mbrSet)
Retrieve all INVALID email from the specified mail and member Set.
|
static java.lang.String |
getLocalPartSuffixAuthKey(Member mbr)
Returns a localpart suffix authkey for given Member.
|
MailFetcher |
getMailFetcher()
Returns the MailFetcher
|
java.lang.String |
getMessageIdQuietly(javax.mail.Message msg)
Convenient method that delegate to MailFetcher method
|
static void |
improveMailMessageConformity(MailMessage msg,
java.util.HashMap<java.lang.String,java.lang.Object> ctxt)
Improve the specified MailMessage conformity with mail sending best practices (if enabled).
|
void |
init() |
static java.lang.String |
replaceRelativeUrlsWithAbsoluteUrls(java.lang.String contentHtml)
Convert all relative URLs inside the specified HTML content into absolute URL.
|
static java.util.Set<Member> |
resolveAddress(java.util.Set<java.lang.String> addressSet)
Retrieves the set of Members given the set of E-mail addresses.
|
static Member |
resolveAddress(java.lang.String addr)
Retrieves the Member from the given E-mail.
|
static void |
resolveAddresses(MailMessage mail)
Updates the given mailMessage's addresses field.
|
void |
saveDBMailMessage(MailMessage mail,
java.util.Map<java.lang.String,java.lang.Object> context)
Build a DBMessage from a Message and save in into the DB
|
java.io.File |
writeEml(javax.mail.Message msg) |
public static final java.lang.String REVISION
public static final java.lang.String SEND_WITH_SITE_EMAIL
The value is a boolean which defines if MailMessage should be sent using the
Member name and e-mail, or using the user name but with the site e-mail address.
If set to true
, mail are sent using the site default email address,
and the original Member is used in the ReplyTo header.
If set to false
, mail are sent using original member email address.
Value can be specified :
MailMessage.send(HashMap)
method (this value overrides the behavior of JCMS property)public static final java.lang.String ADD_IMAGES_AUTHKEY
The value is a boolean which defines if MailMessage should be modified to
add authentication key to all images source URL to allow images to mailer without
any authentication.
If set to true
, authkey are added to URL.
If set to false
, default behavior is applied.
Value can be specified :
MailMessage.send(HashMap)
method (this value overrides the behavior of JCMS property)public static MailManager getInstance()
public void init()
public static void improveMailMessageConformity(MailMessage msg, java.util.HashMap<java.lang.String,java.lang.Object> ctxt)
Implementation details
If following criterias are met :
mail.send-with-site-email
is set to true
mail.send-with-site-email
is either undefined or
set to true
in the context map (this attribute overrides behavior of JCMS property)MailMessage.getFromMember()
is not null
MailMessage.getReplyToMember()
is null
or is the same member specified in MailMessage.getFromMember()
"{Member Full Name} ({Site Name}) <{default-email or admin-email}>"
msg
- the MailMessage to modify if criterias are metctxt
- the context map attribute of MailMessage.send(HashMap)
, MUST NOT be nullpublic static void addAuthKeyToImagesSrc(MailMessage msg, java.util.HashMap<java.lang.String,java.lang.Object> ctxt)
It allows mailer to access images without any authentication.
Default behavior is to perform this operation only when the site is private.
Since improvement JCMS-2677, the operation can be forced if :
mail.add-images-authkey
is set to true
mail.add-images-authkey
is set to true
in the context map (this attribute overrides behavior of JCMS property)Authkeys are added only if the message is sent on one and only one Member.
msg
- the MailMessage to modify if criterias are metctxt
- the context map attribute of MailMessage.send(HashMap)
, MUST NOT be nullpublic static java.lang.String addAuthKeyToImagesSrc(java.lang.String content, Member mbr)
All image URL in tag src='...' are modified to add an authkey.
content
- html content to updatembr
- the recipient memberpublic static java.lang.String replaceRelativeUrlsWithAbsoluteUrls(java.lang.String contentHtml)
Uses the current channel URL as prefix of relative URL.
contentHtml
- the HTML content in which to look for relative URL (in src and href attributes)public java.util.Set<java.lang.Object> getDBMailMessageSet(java.lang.String[] ids)
ids
- a list of Message-IDpublic int getDBMailMessageCount()
public int getDBMailMessageCount(java.lang.String account)
account
- the account namepublic MailMessage getDBMailMessage(javax.mail.Message msg)
msg
- a javax.mail.Messagepublic MailMessage getDBMailMessage(java.lang.String msgid)
msgid
- the message idpublic java.util.Collection<? extends MailMessage> getDBMailMessageReplies(java.lang.String msgid)
msgid
- the message idpublic java.util.Collection<? extends MailMessage> getDBMailMessageThread(java.lang.String thread)
public MailMessage createDBMailMessage(javax.mail.Message msg, MailAccount account)
msg
- a javax.mail.Messageaccount
- the mailAccountpublic void saveDBMailMessage(MailMessage mail, java.util.Map<java.lang.String,java.lang.Object> context)
mail
- the MailMessagecontext
- the contextual mappublic java.io.File writeEml(javax.mail.Message msg)
public MailFetcher getMailFetcher()
public java.lang.String getMessageIdQuietly(javax.mail.Message msg)
msg
- the javax.mail.MessageMailFetcher.getMessageIdQuietly(Message)
public static java.lang.String getIncomingAddress(java.lang.String localpart, Member mbr, java.lang.String label)
localpart
- the mail prefixmbr
- Member author of the maillabel
- the email labelpublic static java.lang.String getLocalPartSuffixAuthKey(Member mbr)
mbr
- the memberpublic static java.util.Set<javax.mail.internet.InternetAddress> getIAFromMemberSet(java.util.Set<Member> mbrSet) throws javax.mail.MessagingException
mbrSet
- a Set of Membersjavax.mail.MessagingException
- a base class for all exceptions thrown by the Messaging classespublic static java.util.TreeSet<java.lang.String> getInvalidEmailSet(java.util.Set<java.lang.String> mailSet, java.util.Set<Member> mbrSet)
mailSet
- a set of email addressesmbrSet
- a set of Memberpublic static java.lang.String buildContentFromJsp(java.lang.String jspPath, Member loggedMember, java.lang.String language, java.util.HashMap<java.lang.Object,java.lang.Object> requestAttributeMap, java.util.HashMap<java.lang.Object,java.lang.Object> sessionAttributeMap)
jspPath
- the jsp to processloggedMember
- the loggedMemberlanguage
- the user languagerequestAttributeMap
- Map of request attributessessionAttributeMap
- Map of session attributespublic static void resolveAddresses(MailMessage mail)
String addresses will be resolved to Members if possible.
Optionnal already set Members will be kept.
mail
- the mail to resolved String email to Members.public static Member resolveAddress(java.lang.String addr)
addr
- an email address that will be parsed using
MailUtil.getInternetAddress(String)
public static java.util.Set<Member> resolveAddress(java.util.Set<java.lang.String> addressSet)
Retrieved Member's E-mail will be removed from addressSet when resolved.
addressSet
- the set of E-mails to retrieve their related Member if anyCopyright © 2001-2017 Jalios SA. All Rights Reserved.