use of org.broadleafcommerce.common.email.service.info.EmailInfo in project BroadleafCommerce by BroadleafCommerce.
the class MessageCreator method buildMimeMessagePreparator.
public MimeMessagePreparator buildMimeMessagePreparator(final Map<String, Object> props) {
MimeMessagePreparator preparator = new MimeMessagePreparator() {
@Override
public void prepare(MimeMessage mimeMessage) throws Exception {
EmailTarget emailUser = (EmailTarget) props.get(EmailPropertyType.USER.getType());
EmailInfo info = (EmailInfo) props.get(EmailPropertyType.INFO.getType());
boolean isMultipart = CollectionUtils.isNotEmpty(info.getAttachments());
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, info.getEncoding());
message.setTo(emailUser.getEmailAddress());
message.setFrom(info.getFromAddress());
message.setSubject(info.getSubject());
if (emailUser.getBCCAddresses() != null && emailUser.getBCCAddresses().length > 0) {
message.setBcc(emailUser.getBCCAddresses());
}
if (emailUser.getCCAddresses() != null && emailUser.getCCAddresses().length > 0) {
message.setCc(emailUser.getCCAddresses());
}
String messageBody = info.getMessageBody();
if (messageBody == null) {
messageBody = buildMessageBody(info, props);
}
message.setText(messageBody, true);
for (Attachment attachment : info.getAttachments()) {
ByteArrayDataSource dataSource = new ByteArrayDataSource(attachment.getData(), attachment.getMimeType());
message.addAttachment(attachment.getFilename(), dataSource);
}
}
};
return preparator;
}
use of org.broadleafcommerce.common.email.service.info.EmailInfo in project BroadleafCommerce by BroadleafCommerce.
the class EmailNotificationPasswordUpdatedHandler method passwordChanged.
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void passwordChanged(PasswordReset passwordReset, Customer customer, String newPassword) {
Locale localeToUse = null;
org.broadleafcommerce.common.locale.domain.Locale blLocale = customer.getCustomerLocale();
if (blLocale != null) {
String[] splitLocale = blLocale.getLocaleCode().split("_");
if (splitLocale.length > 1) {
localeToUse = new Locale(splitLocale[0], splitLocale[1]);
} else {
localeToUse = new Locale(splitLocale[0]);
}
}
if (localeToUse == null) {
localeToUse = getPasswordResetEmailDefaultLocale();
}
String subject = getPasswordResetEmailSubject().get(localeToUse);
if (subject == null) {
LOG.warn("Unable to find an email subject for customer locale: " + localeToUse.toString() + ". Using default locale instead.");
subject = getPasswordResetEmailSubject().get(getPasswordResetEmailDefaultLocale());
}
String template = getPasswordResetEmailTemplate().get(localeToUse);
if (template == null) {
LOG.warn("Unable to find an email template for customer locale: " + localeToUse.toString() + ". Using default locale instead.");
template = getPasswordResetEmailTemplate().get(getPasswordResetEmailDefaultLocale());
}
EmailInfo info = new EmailInfo();
info.setFromAddress(getPasswordResetEmailFromAddress());
info.setSubject(subject);
info.setEmailTemplate(template);
info.setSendEmailReliableAsync(String.valueOf(passwordReset.isSendResetEmailReliableAsync()));
HashMap vars = constructPasswordChangeEmailTemplateVariables(customer, newPassword);
emailService.sendTemplateEmail(passwordReset.getEmail(), info, vars);
}
use of org.broadleafcommerce.common.email.service.info.EmailInfo in project BroadleafCommerce by BroadleafCommerce.
the class AdminSpringBootTestConfiguration method blForgotPasswordEmailInfo.
@Bean
public EmailInfo blForgotPasswordEmailInfo() {
EmailInfo info = blEmailInfo();
info.setSubject("Reset password request");
info.setEmailTemplate("resetPassword-email");
return info;
}
use of org.broadleafcommerce.common.email.service.info.EmailInfo in project BroadleafCommerce by BroadleafCommerce.
the class AdminSpringBootTestConfiguration method blReturnAuthorizationEmailInfo.
@Bean
public EmailInfo blReturnAuthorizationEmailInfo() {
EmailInfo info = blEmailInfo();
info.setSubject("Your return with The Heat Clinic");
info.setEmailTemplate("returnAuthorization-email");
return info;
}
use of org.broadleafcommerce.common.email.service.info.EmailInfo in project BroadleafCommerce by BroadleafCommerce.
the class AdminSpringBootTestConfiguration method blOrderConfirmationEmailInfo.
@Bean
public EmailInfo blOrderConfirmationEmailInfo() {
EmailInfo info = blEmailInfo();
info.setSubject("Your order with The Heat Clinic");
info.setEmailTemplate("orderConfirmation-email");
return info;
}
Aggregations