Class DefaultEmailService
java.lang.Object
de.hybris.platform.acceleratorservices.email.impl.DefaultEmailService
- All Implemented Interfaces:
EmailService
Service to create and send emails.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddReplyTo(EmailMessageModel message, org.apache.commons.mail.HtmlEmail email) convertToStrings(List<EmailAddressModel> addresses) protected MediaModelcreateBodyMedia(String bodyMediaName, String body) Method creates MediaModel object for storing email bodycreateEmailAttachment(DataInputStream masterDataStream, String filename, String mimeType) Creates an email attachment from an input stream.createEmailMessage(List<EmailAddressModel> toAddresses, List<EmailAddressModel> ccAddresses, List<EmailAddressModel> bccAddresses, EmailAddressModel fromAddress, String replyToAddress, String subject, String body, List<EmailAttachmentModel> attachments) Creates and EmailMessage object.protected javax.mail.internet.InternetAddresscreateInternetAddress(String emailAddress, String displayName) protected Collection<javax.mail.internet.InternetAddress>getAddresses(List<EmailAddressModel> emailAddresses) protected StringgetBody(EmailMessageModel message) Method checks which attribute is storing email body (bodyMedia or body) and return its content as stringprotected CatalogServiceprotected CatalogVersionModelprotected CatalogVersionServiceprotected ConfigurationServiceprotected EmailAddressFetchStrategyprotected MediaFolderModelprotected Stringprotected MediaFolderModelprotected Stringprotected MediaServiceprotected ModelServicegetOrCreateEmailAddressForEmail(String emailAddress, String displayName) Returns aEmailAddressModel.protected org.apache.commons.mail.HtmlEmailprotected voidprotected voidlogInfo(EmailMessageModel message, org.apache.commons.mail.EmailException e) protected StringnullifyEmpty(String str) protected booleanprocessAttachmentsSuccessful(org.apache.commons.mail.HtmlEmail email, List<EmailAttachmentModel> attachments) booleansend(EmailMessageModel message) Sends an emailprotected voidsetAddresses(EmailMessageModel message, org.apache.commons.mail.HtmlEmail email, List<EmailAddressModel> toAddresses) voidsetCatalogService(CatalogService catalogService) voidsetCatalogVersionService(CatalogVersionService catalogVersionService) voidsetConfigurationService(ConfigurationService configurationService) voidsetEmailAddressFetchStrategy(EmailAddressFetchStrategy emailAddressFetchStrategy) voidsetEmailAttachmentsMediaFolderName(String emailAttachmentsMediaFolderName) voidsetEmailBodyMediaFolderName(String emailBodyMediaFolderName) voidsetMediaService(MediaService mediaService) voidsetModelService(ModelService modelService) protected voidvalidateAddresses(List<EmailAddressModel> toAddresses, EmailAddressModel fromAddress) protected voidvalidateContent(String subject, String body) protected voidvalidateEmailAddress(String address, String type)
-
Field Details
-
EMAIL_BODY_ENCODING
Deprecated, for removal: This API element is subject to removal in a future version.As of release 6.7, replaced byStandardCharsets.UTF_8- See Also:
-
EMAILSERVICE_SEND_ENABLED_CONFIG_KEY
- See Also:
-
EMAIL_BODY_MAX_LENGTH
public static final int EMAIL_BODY_MAX_LENGTH- See Also:
-
EMAIL_BODY_MAX_LENGTH_KEY
- See Also:
-
EMAIL_BODY_MIME_TYPE
- See Also:
-
-
Constructor Details
-
DefaultEmailService
public DefaultEmailService()
-
-
Method Details
-
getOrCreateEmailAddressForEmail
Description copied from interface:EmailServiceReturns aEmailAddressModel. Instance is found for the given email address and display name criteria. If there is no instance for this condition the newEmailAddressModelinstance is returned based on the given criteria.- Specified by:
getOrCreateEmailAddressForEmailin interfaceEmailService- Parameters:
emailAddress- Email iddisplayName- Display name- Returns:
- EmailAddress object
-
createEmailAttachment
public EmailAttachmentModel createEmailAttachment(DataInputStream masterDataStream, String filename, String mimeType) Description copied from interface:EmailServiceCreates an email attachment from an input stream.- Specified by:
createEmailAttachmentin interfaceEmailService- Parameters:
masterDataStream- Input data streamfilename- File namemimeType- Mime type- Returns:
- EmailAttachment object
-
getEmailAttachmentsMediaFolder
-
getEmailBodyMediaFolder
-
createEmailMessage
public EmailMessageModel createEmailMessage(List<EmailAddressModel> toAddresses, List<EmailAddressModel> ccAddresses, List<EmailAddressModel> bccAddresses, EmailAddressModel fromAddress, String replyToAddress, String subject, String body, List<EmailAttachmentModel> attachments) Description copied from interface:EmailServiceCreates and EmailMessage object.- Specified by:
createEmailMessagein interfaceEmailService- Parameters:
toAddresses- List of To email addressesccAddresses- List of CC email addressesbccAddresses- List of BCC email addressesfromAddress- From email addressreplyToAddress- Reply To email addresssubject- Subject of the emailbody- Contents of the emailattachments- List of email attachments- Returns:
- EmailMessage object
-
validateAddresses
protected void validateAddresses(List<EmailAddressModel> toAddresses, EmailAddressModel fromAddress) -
validateContent
-
createBodyMedia
Method creates MediaModel object for storing email body- Parameters:
bodyMediaName- - name for created objectbody- - content of email body- Returns:
- created MediaModel object
-
getCatalogVersion
-
validateEmailAddress
-
send
Description copied from interface:EmailServiceSends an email- Specified by:
sendin interfaceEmailService- Parameters:
message- EmailMessage- Returns:
- true if successful
-
addReplyTo
protected void addReplyTo(EmailMessageModel message, org.apache.commons.mail.HtmlEmail email) throws org.apache.commons.mail.EmailException - Throws:
org.apache.commons.mail.EmailException
-
logInfo
-
processAttachmentsSuccessful
protected boolean processAttachmentsSuccessful(org.apache.commons.mail.HtmlEmail email, List<EmailAttachmentModel> attachments) -
setAddresses
protected void setAddresses(EmailMessageModel message, org.apache.commons.mail.HtmlEmail email, List<EmailAddressModel> toAddresses) throws org.apache.commons.mail.EmailException - Throws:
org.apache.commons.mail.EmailException
-
getPerConfiguredEmail
protected org.apache.commons.mail.HtmlEmail getPerConfiguredEmail() throws org.apache.commons.mail.EmailException- Throws:
org.apache.commons.mail.EmailException
-
getBody
Method checks which attribute is storing email body (bodyMedia or body) and return its content as string- Parameters:
message- - email message object- Returns:
- email body
-
nullifyEmpty
-
getAddresses
protected Collection<javax.mail.internet.InternetAddress> getAddresses(List<EmailAddressModel> emailAddresses) -
createInternetAddress
protected javax.mail.internet.InternetAddress createInternetAddress(String emailAddress, String displayName) throws org.apache.commons.mail.EmailException - Throws:
org.apache.commons.mail.EmailException
-
convertToStrings
-
logDebugException
-
getEmailAddressFetchStrategy
-
setEmailAddressFetchStrategy
-
getEmailAttachmentsMediaFolderName
-
setEmailAttachmentsMediaFolderName
-
getEmailBodyMediaFolderName
-
setEmailBodyMediaFolderName
-
getModelService
-
setModelService
-
getMediaService
-
setMediaService
-
getConfigurationService
-
setConfigurationService
-
getCatalogVersionService
-
setCatalogVersionService
-
getCatalogService
-
setCatalogService
-
StandardCharsets.UTF_8