/** * @param tenant the tenant of the shop the customer checked out from * @param customerEmail the email of the customer * @param locale the locale of the customer * @return an optional notification email object, present if all information is there and valid and the template * exists, absent otherwise */ private MailTemplate getCustomerNotificationEmail(Tenant tenant, String customerEmail, Locale locale) { return new MailTemplate() .from(getTenantContactEmail(tenant)) .to(customerEmail) .template("order-paid-customer") .locale(locale); }
private void sendPasswordResetMail(User user, final String secret, AccountsSettings settings) { MailTemplate mailTemplate = new MailTemplate().template("password-reset").to(user.getEmail()) .from(generalSettings.getNotificationsEmail()); try { Map<String, Object> context = Maps.newHashMap(); for (UserDataSupplier supplier : userDataSuppliers.values()) { supplier.supply(user, context); } String passwordResetUriLink; if (!Strings.isNullOrEmpty(settings.getUserPasswordResetUriTemplate().getValue())) { passwordResetUriLink = settings.getUserPasswordResetUriTemplate().getValue(); } else { passwordResetUriLink = urlHelper.getContextWebURL("/login/reset-password/${resetKey}").toString(); } SimpleTemplateEngine templateEngine = new SimpleTemplateEngine(); groovy.text.Template uriTemplate = templateEngine.createTemplate(passwordResetUriLink); context.put("resetLink", uriTemplate.make(new HashMap() { { put("resetKey", secret); } }).toString()); context.put("siteName", siteSettings.getName()); mailTemplateService.sendTemplateMail(mailTemplate, context); } catch (MailException | ClassNotFoundException | IOException e) { logger.error("Failed to send validation email", e); } }
private void sendValidationMail(final User createdUser, AccountsSettings settings, Map<String, Object> additionalContext) { MailTemplate mailTemplate = new MailTemplate().template("account-validation").to(createdUser.getEmail()) .from(generalSettings.getNotificationsEmail()); try { Map<String, Object> context = Maps.newHashMap(); context.putAll(additionalContext); String validationUriTemplate; if (!Strings.isNullOrEmpty(settings.getUserValidationUriTemplate().getValue())) { validationUriTemplate = settings.getUserValidationUriTemplate().getValue(); } else { validationUriTemplate = urlHelper.getContextWebURL("/account/validation/${validationKey}").toString(); } SimpleTemplateEngine templateEngine = new SimpleTemplateEngine(); groovy.text.Template uriTemplate = templateEngine.createTemplate(validationUriTemplate); context.put("validationLink", uriTemplate.make(new HashMap() { { put("validationKey", createdUser.getValidationKey()); } }).toString()); context.put("siteName", siteSettings.getName()); mailTemplateService.sendTemplateMail(mailTemplate, context); } catch (MailException | ClassNotFoundException | IOException e) { logger.error("Failed to send validation email", e); } }
/** * @param tenant the tenant of the shop the customer checked out from * @param locale the main locale of the tenant * @return an optional notification email object, present if all information is there and valid and the template * exists, absent otherwise */ private MailTemplate getTenantNotificationEmail(Tenant tenant, Locale locale) { return new MailTemplate() .from(generalSettings.getNotificationsEmail()) .to(getTenantContactEmail(tenant)) .template("order-paid-tenant") .locale(locale); }