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
Default implementation for sending mails via smtp
- Author:
- XIMA MEDIA GmbH, Dresden
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Predicate<javax.mail.Address>
protected IMailServerData
-
Method Summary
Modifier and TypeMethodDescriptionvoid
archive
(IBaseMailData mail, Mandant client, File file) Create an archived file of the mail.protected ISendMailReport
buildAndSendMessage
(IBaseMailData mail, Mandant client) protected javax.mail.Authenticator
protected javax.mail.internet.MimeBodyPart
buildBodyPart
(BodyPartData body) protected void
buildContent
(IBaseMailData mail, javax.mail.internet.MimeMessage msg, Mandant client) protected javax.mail.internet.MimeBodyPart
buildFilePart
(FilePartData file) protected Properties
protected javax.mail.internet.MimeMessage
createMimeMessage
(IBaseMailData mail, Mandant client) protected javax.mail.internet.MimeMessage
createMimeMessage
(javax.mail.Session session, IBaseMailData mail, Mandant client) protected final void
enforceSenderAddress
(javax.mail.internet.MimeMessage msg, Mandant client) protected javax.mail.Address[]
filterAddresses
(javax.mail.Address[] addresses) Gets the mail server data of the contextsendWithReport
(IBaseMailData mail) Sends a mail based on the given datasendWithReport
(IBaseMailData mail, Mandant client) Sends a mail based on the given datavoid
setAddressFilter
(Predicate<javax.mail.Address> addressFilter) Sets an filter for excluding mail addresses during sendMethods 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 Details
-
addressFilter
-
serverData
-
-
Method Details
-
getServerData
Description copied from interface:IMailContext
Gets the mail server data of the context- Specified by:
getServerData
in interfaceIMailContext
- Returns:
- the server data
-
setAddressFilter
Description copied from interface:IMailContext
Sets an filter for excluding mail addresses during send- Specified by:
setAddressFilter
in interfaceIMailContext
- Parameters:
addressFilter
- the address filter to set
-
buildAuthenticator
protected javax.mail.Authenticator buildAuthenticator() -
buildProperties
-
sendWithReport
Description copied from interface:IMailContext
Sends a mail based on the given data- Specified by:
sendWithReport
in 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.
-
sendWithReport
Description copied from interface:IMailContext
Sends a mail based on the given data- Specified by:
sendWithReport
in 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.
-
archive
Description copied from interface:IMailContext
Create an archived file of the mail.- Specified by:
archive
in 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.
-
buildAndSendMessage
- Throws:
Exception
-
enforceSenderAddress
protected final void enforceSenderAddress(javax.mail.internet.MimeMessage msg, Mandant client) throws javax.mail.MessagingException - Throws:
javax.mail.MessagingException
-
createMimeMessage
protected javax.mail.internet.MimeMessage createMimeMessage(IBaseMailData mail, Mandant client) throws javax.mail.MessagingException - Throws:
javax.mail.MessagingException
-
createMimeMessage
protected javax.mail.internet.MimeMessage createMimeMessage(javax.mail.Session session, IBaseMailData mail, Mandant client) throws javax.mail.MessagingException - Throws:
javax.mail.MessagingException
-
filterAddresses
protected javax.mail.Address[] filterAddresses(javax.mail.Address[] addresses) -
buildContent
protected void buildContent(IBaseMailData mail, javax.mail.internet.MimeMessage msg, Mandant client) throws javax.mail.MessagingException - Throws:
javax.mail.MessagingException
-
buildBodyPart
- Throws:
Exception
-
buildFilePart
- Throws:
Exception
-