Package de.xima.fc.mail.impl.context
Class DefaultMailContext
- java.lang.Object
-
- de.xima.fc.mail.impl.context.DefaultMailContext
-
- All Implemented Interfaces:
IMailContext
- Direct Known Subclasses:
MSGraphMailContext,PasswordMailContext
public class DefaultMailContext extends Object implements IMailContext
Default implementation for sending mails via smtp- Author:
- XIMA MEDIA GmbH, Dresden
-
-
Field Summary
Fields Modifier and Type Field Description protected Predicate<javax.mail.Address>addressFilterprotected IMailServerDataserverData
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidarchive(IBaseMailData mail, Mandant client, File file)Create an archived file of the mail.protected ISendMailReportbuildAndSendMessage(IBaseMailData mail, Mandant client)protected javax.mail.AuthenticatorbuildAuthenticator()protected javax.mail.internet.MimeBodyPartbuildBodyPart(BodyPartData body)protected voidbuildContent(IBaseMailData mail, javax.mail.internet.MimeMessage msg, Mandant client)Deprecated, for removal: This API element is subject to removal in a future version.since 8.5.0, usebuildContentWithSecurityReport(IBaseMailData, MimeMessage, Mandant)instead.protected org.apache.commons.lang3.tuple.Pair<javax.mail.internet.MimeMessage,IMailSecurityReport>buildContentWithSecurityReport(IBaseMailData mail, javax.mail.internet.MimeMessage msg, Mandant client)protected javax.mail.internet.MimeBodyPartbuildFilePart(FilePartData file)protected PropertiesbuildProperties()protected javax.mail.internet.MimeMessagecreateMimeMessage(IBaseMailData mail, Mandant client)Deprecated, for removal: This API element is subject to removal in a future version.since 8.5.0, usecreateMimeMessageWithSecurityReport(IBaseMailData, Mandant)instead.protected javax.mail.internet.MimeMessagecreateMimeMessage(javax.mail.Session session, IBaseMailData mail, Mandant client)Deprecated, for removal: This API element is subject to removal in a future version.since 8.5.0, usecreateMimeMessageWithSecurityReport(Session, IBaseMailData, Mandant)instead.protected org.apache.commons.lang3.tuple.Pair<javax.mail.internet.MimeMessage,IMailSecurityReport>createMimeMessageWithSecurityReport(IBaseMailData mail, Mandant client)protected org.apache.commons.lang3.tuple.Pair<javax.mail.internet.MimeMessage,IMailSecurityReport>createMimeMessageWithSecurityReport(javax.mail.Session session, IBaseMailData mail, Mandant client)protected voidenforceSenderAddress(javax.mail.internet.MimeMessage msg, Mandant client)protected javax.mail.Address[]filterAddresses(javax.mail.Address[] addresses)IMailServerDatagetServerData()Gets the mail server data of the contextISendMailReportsendWithReport(IBaseMailData mail)Sends a mail based on the given dataISendMailReportsendWithReport(IBaseMailData mail, Mandant client)Sends a mail based on the given datavoidsetAddressFilter(Predicate<javax.mail.Address> addressFilter)Sets an filter for excluding mail addresses during send-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.xima.fc.mail.interfaces.IMailContext
send, send, setAddressFilter
-
-
-
-
Field Detail
-
addressFilter
protected Predicate<javax.mail.Address> addressFilter
-
serverData
protected IMailServerData serverData
-
-
Method Detail
-
archive
public void archive(IBaseMailData mail, Mandant client, File file) throws Exception
Description copied from interface:IMailContextCreate an archived file of the mail.- Specified by:
archivein interfaceIMailContext- Parameters:
mail- Data of the email to send.client- The client to use for placeholder replacements.file- The file to write to.- Throws:
Exception- When the archive file could not be created.
-
getServerData
public IMailServerData getServerData()
Description copied from interface:IMailContextGets the mail server data of the context- Specified by:
getServerDatain interfaceIMailContext- Returns:
- the server data
-
sendWithReport
public ISendMailReport sendWithReport(IBaseMailData mail, Mandant client) throws Exception
Description copied from interface:IMailContextSends a mail based on the given data- Specified by:
sendWithReportin interfaceIMailContext- Parameters:
mail- Data with the mail or mails to sent.client- The client scope to use for placeholder replacements- Returns:
- Information about the mails that were actually sent.
- Throws:
Exception- When the mail could not be sent, e.g. due to network errors or invalid mail addresses.
-
sendWithReport
public ISendMailReport sendWithReport(IBaseMailData mail) throws Exception
Description copied from interface:IMailContextSends a mail based on the given data- Specified by:
sendWithReportin interfaceIMailContext- Parameters:
mail- Data with the mail or mails to sent.- Returns:
- Information about the mails that were actually sent.
- Throws:
Exception- When the mail could not be sent, e.g. due to network errors or invalid mail addresses.
-
setAddressFilter
public void setAddressFilter(Predicate<javax.mail.Address> addressFilter)
Description copied from interface:IMailContextSets an filter for excluding mail addresses during send- Specified by:
setAddressFilterin interfaceIMailContext- Parameters:
addressFilter- the address filter to set
-
buildAndSendMessage
protected ISendMailReport buildAndSendMessage(IBaseMailData mail, Mandant client) throws Exception
- Throws:
Exception
-
buildAuthenticator
protected javax.mail.Authenticator buildAuthenticator()
-
buildBodyPart
protected javax.mail.internet.MimeBodyPart buildBodyPart(BodyPartData body) throws Exception
- Throws:
Exception
-
buildContent
@Deprecated(since="8.5.0", forRemoval=true) protected void buildContent(IBaseMailData mail, javax.mail.internet.MimeMessage msg, Mandant client) throws javax.mail.MessagingException
Deprecated, for removal: This API element is subject to removal in a future version.since 8.5.0, usebuildContentWithSecurityReport(IBaseMailData, MimeMessage, Mandant)instead.- Throws:
javax.mail.MessagingException
-
buildContentWithSecurityReport
protected org.apache.commons.lang3.tuple.Pair<javax.mail.internet.MimeMessage,IMailSecurityReport> buildContentWithSecurityReport(IBaseMailData mail, javax.mail.internet.MimeMessage msg, Mandant client) throws javax.mail.MessagingException
- Throws:
javax.mail.MessagingException
-
buildFilePart
protected javax.mail.internet.MimeBodyPart buildFilePart(FilePartData file) throws Exception
- Throws:
Exception
-
buildProperties
protected Properties buildProperties()
-
createMimeMessage
@Deprecated(since="8.5.0", forRemoval=true) protected javax.mail.internet.MimeMessage createMimeMessage(IBaseMailData mail, Mandant client) throws javax.mail.MessagingException
Deprecated, for removal: This API element is subject to removal in a future version.since 8.5.0, usecreateMimeMessageWithSecurityReport(IBaseMailData, Mandant)instead.- Throws:
javax.mail.MessagingException
-
createMimeMessage
@Deprecated(since="8.5.0", forRemoval=true) protected javax.mail.internet.MimeMessage createMimeMessage(javax.mail.Session session, IBaseMailData mail, Mandant client) throws javax.mail.MessagingException
Deprecated, for removal: This API element is subject to removal in a future version.since 8.5.0, usecreateMimeMessageWithSecurityReport(Session, IBaseMailData, Mandant)instead.- Throws:
javax.mail.MessagingException
-
createMimeMessageWithSecurityReport
protected org.apache.commons.lang3.tuple.Pair<javax.mail.internet.MimeMessage,IMailSecurityReport> createMimeMessageWithSecurityReport(javax.mail.Session session, IBaseMailData mail, Mandant client) throws javax.mail.MessagingException
- Throws:
javax.mail.MessagingException
-
createMimeMessageWithSecurityReport
protected org.apache.commons.lang3.tuple.Pair<javax.mail.internet.MimeMessage,IMailSecurityReport> createMimeMessageWithSecurityReport(IBaseMailData mail, Mandant client) throws javax.mail.MessagingException
- Throws:
javax.mail.MessagingException
-
enforceSenderAddress
protected final void enforceSenderAddress(javax.mail.internet.MimeMessage msg, Mandant client) throws javax.mail.MessagingException- Throws:
javax.mail.MessagingException
-
filterAddresses
protected javax.mail.Address[] filterAddresses(javax.mail.Address[] addresses)
-
-