use of com.salesmanager.core.business.modules.email.Email in project shopizer by shopizer-ecommerce.
the class UserFacadeImpl method resetPasswordRequest.
@Async
private void resetPasswordRequest(User user, String resetLink, MerchantStore store, Locale locale) throws Exception {
try {
Map<String, String> templateTokens = emailUtils.createEmailObjectsMap(imageUtils.getContextPath(), store, messages, locale);
templateTokens.put(EmailConstants.LABEL_HI, messages.getMessage("label.generic.hi", locale));
templateTokens.put(EmailConstants.EMAIL_USER_FIRSTNAME, user.getFirstName());
templateTokens.put(RESET_PASSWORD_LINK, resetLink);
templateTokens.put(RESET_PASSWORD_TEXT, messages.getMessage("email.reset.password.text", new String[] { store.getStorename() }, locale));
templateTokens.put(EmailConstants.LABEL_LINK_TITLE, messages.getMessage("email.link.reset.password.title", locale));
templateTokens.put(EmailConstants.LABEL_LINK, messages.getMessage("email.link", locale));
Email email = new Email();
email.setFrom(store.getStorename());
email.setFromEmail(store.getStoreEmailAddress());
email.setSubject(messages.getMessage("email.link.reset.password.title", locale));
email.setTo(user.getAdminEmail());
email.setTemplateName(ACCOUNT_PASSWORD_RESET_TPL);
email.setTemplateTokens(templateTokens);
emailService.sendHtmlEmail(store, email);
} catch (Exception e) {
throw new Exception("Cannot send email to customer", e);
}
}
use of com.salesmanager.core.business.modules.email.Email in project shopizer by shopizer-ecommerce.
the class EmailTemplatesUtils method sendContactEmail.
@Async
public void sendContactEmail(ContactForm contact, MerchantStore merchantStore, Locale storeLocale, String contextPath) {
/**
* issue with putting that elsewhere *
*/
LOGGER.info("Sending email to store owner");
try {
Map<String, String> templateTokens = emailUtils.createEmailObjectsMap(contextPath, merchantStore, messages, storeLocale);
templateTokens.put(EmailConstants.EMAIL_CONTACT_NAME, contact.getName());
templateTokens.put(EmailConstants.EMAIL_CONTACT_EMAIL, contact.getEmail());
templateTokens.put(EmailConstants.EMAIL_CONTACT_CONTENT, contact.getComment());
String[] contactSubject = { contact.getSubject() };
templateTokens.put(EmailConstants.EMAIL_CUSTOMER_CONTACT, messages.getMessage("email.contact", contactSubject, storeLocale));
templateTokens.put(EmailConstants.EMAIL_CONTACT_NAME_LABEL, messages.getMessage("label.entity.name", storeLocale));
templateTokens.put(EmailConstants.EMAIL_CONTACT_EMAIL_LABEL, messages.getMessage("label.generic.email", storeLocale));
Email email = new Email();
email.setFrom(contact.getName());
// since shopizer sends email to store email, sender is store email
email.setFromEmail(merchantStore.getStoreEmailAddress());
email.setSubject(messages.getMessage("email.contact.title", storeLocale));
// contact has to be delivered to store owner, receiver is store email
email.setTo(merchantStore.getStoreEmailAddress());
email.setTemplateName(EmailConstants.EMAIL_CONTACT_TMPL);
email.setTemplateTokens(templateTokens);
LOGGER.debug("Sending contact email");
emailService.sendHtmlEmail(merchantStore, email);
} catch (Exception e) {
LOGGER.error("Error occured while sending contact email ", e);
}
}
use of com.salesmanager.core.business.modules.email.Email in project shopizer by shopizer-ecommerce.
the class EmailTemplatesUtils method sendRegistrationEmail.
/**
* Sends an email to the customer after registration
* @param request
* @param customer
* @param merchantStore
* @param customerLocale
*/
@Async
public void sendRegistrationEmail(PersistableCustomer customer, MerchantStore merchantStore, Locale customerLocale, String contextPath) {
/**
* issue with putting that elsewhere *
*/
LOGGER.info("Sending welcome email to customer");
try {
Map<String, String> templateTokens = emailUtils.createEmailObjectsMap(contextPath, merchantStore, messages, customerLocale);
templateTokens.put(EmailConstants.LABEL_HI, messages.getMessage("label.generic.hi", customerLocale));
templateTokens.put(EmailConstants.EMAIL_CUSTOMER_FIRSTNAME, customer.getBilling().getFirstName());
templateTokens.put(EmailConstants.EMAIL_CUSTOMER_LASTNAME, customer.getBilling().getLastName());
String[] greetingMessage = { merchantStore.getStorename(), filePathUtils.buildCustomerUri(merchantStore, contextPath), merchantStore.getStoreEmailAddress() };
templateTokens.put(EmailConstants.EMAIL_CUSTOMER_GREETING, messages.getMessage("email.customer.greeting", greetingMessage, customerLocale));
templateTokens.put(EmailConstants.EMAIL_USERNAME_LABEL, messages.getMessage("label.generic.username", customerLocale));
templateTokens.put(EmailConstants.EMAIL_PASSWORD_LABEL, messages.getMessage("label.generic.password", customerLocale));
templateTokens.put(EmailConstants.CUSTOMER_ACCESS_LABEL, messages.getMessage("label.customer.accessportal", customerLocale));
templateTokens.put(EmailConstants.ACCESS_NOW_LABEL, messages.getMessage("label.customer.accessnow", customerLocale));
templateTokens.put(EmailConstants.EMAIL_USER_NAME, customer.getUserName());
templateTokens.put(EmailConstants.EMAIL_CUSTOMER_PASSWORD, customer.getPassword());
// shop url
String customerUrl = filePathUtils.buildStoreUri(merchantStore, contextPath);
templateTokens.put(EmailConstants.CUSTOMER_ACCESS_URL, customerUrl);
Email email = new Email();
email.setFrom(merchantStore.getStorename());
email.setFromEmail(merchantStore.getStoreEmailAddress());
email.setSubject(messages.getMessage("email.newuser.title", customerLocale));
email.setTo(customer.getEmailAddress());
email.setTemplateName(EmailConstants.EMAIL_CUSTOMER_TPL);
email.setTemplateTokens(templateTokens);
LOGGER.debug("Sending email to {} on their registered email id {} ", customer.getBilling().getFirstName(), customer.getEmailAddress());
emailService.sendHtmlEmail(merchantStore, email);
} catch (Exception e) {
LOGGER.error("Error occured while sending welcome email ", e);
}
}
use of com.salesmanager.core.business.modules.email.Email in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method resetPasswordRequest.
@Async
private void resetPasswordRequest(Customer customer, String resetLink, MerchantStore store, Locale locale) throws Exception {
try {
// creation of a user, send an email
String[] storeEmail = { store.getStoreEmailAddress() };
Map<String, String> templateTokens = emailUtils.createEmailObjectsMap(imageUtils.getContextPath(), store, messages, locale);
templateTokens.put(EmailConstants.LABEL_HI, messages.getMessage("label.generic.hi", locale));
templateTokens.put(EmailConstants.EMAIL_CUSTOMER_FIRSTNAME, customer.getBilling().getFirstName());
templateTokens.put(RESET_PASSWORD_LINK, resetLink);
templateTokens.put(RESET_PASSWORD_TEXT, messages.getMessage("email.reset.password.text", new String[] { store.getStorename() }, locale));
templateTokens.put(EmailConstants.LABEL_LINK_TITLE, messages.getMessage("email.link.reset.password.title", locale));
templateTokens.put(EmailConstants.LABEL_LINK, messages.getMessage("email.link", locale));
templateTokens.put(EmailConstants.EMAIL_CONTACT_OWNER, messages.getMessage("email.contactowner", storeEmail, locale));
Email email = new Email();
email.setFrom(store.getStorename());
email.setFromEmail(store.getStoreEmailAddress());
email.setSubject(messages.getMessage("email.link.reset.password.title", locale));
email.setTo(customer.getEmailAddress());
email.setTemplateName(ACCOUNT_PASSWORD_RESET_TPL);
email.setTemplateTokens(templateTokens);
emailService.sendHtmlEmail(store, email);
} catch (Exception e) {
throw new Exception("Cannot send email to customer", e);
}
}
use of com.salesmanager.core.business.modules.email.Email in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method resetPassword.
@Override
public void resetPassword(Customer customer, MerchantStore store, Language language) {
String password = new String(UUID.generateRandomBytes());
String encodedPassword = passwordEncoder.encode(password);
customer.setPassword(encodedPassword);
try {
customerService.saveOrUpdate(customer);
} catch (Exception e) {
throw new ServiceRuntimeException(e);
}
Locale locale = languageService.toLocale(language, store);
try {
// creation of a user, send an email
String[] storeEmail = { store.getStoreEmailAddress() };
Map<String, String> templateTokens = emailUtils.createEmailObjectsMap(imageUtils.getContextPath(), store, messages, locale);
templateTokens.put(EmailConstants.LABEL_HI, messages.getMessage("label.generic.hi", locale));
templateTokens.put(EmailConstants.EMAIL_CUSTOMER_FIRSTNAME, customer.getBilling().getFirstName());
templateTokens.put(EmailConstants.EMAIL_CUSTOMER_LASTNAME, customer.getBilling().getLastName());
templateTokens.put(EmailConstants.EMAIL_RESET_PASSWORD_TXT, messages.getMessage("email.customer.resetpassword.text", locale));
templateTokens.put(EmailConstants.EMAIL_CONTACT_OWNER, messages.getMessage("email.contactowner", storeEmail, locale));
templateTokens.put(EmailConstants.EMAIL_PASSWORD_LABEL, messages.getMessage("label.generic.password", locale));
templateTokens.put(EmailConstants.EMAIL_CUSTOMER_PASSWORD, password);
Email email = new Email();
email.setFrom(store.getStorename());
email.setFromEmail(store.getStoreEmailAddress());
email.setSubject(messages.getMessage("label.generic.changepassword", locale));
email.setTo(customer.getEmailAddress());
email.setTemplateName(RESET_PASSWORD_TPL);
email.setTemplateTokens(templateTokens);
emailService.sendHtmlEmail(store, email);
} catch (Exception e) {
LOG.error("Cannot send email to customer", e);
}
}
Aggregations