use of org.springframework.mail.javamail.MimeMailMessage in project cshop by erafaelmanuel.
the class ConfirmationMail method constructMail.
public MimeMailMessage constructMail(Token token, String url, Locale locale) {
try {
final String address = messageSource.getMessage(EMAIL, null, locale);
final String recipientAddress = token.getUser().getEmail();
final String title = messageSource.getMessage(TITLE, null, locale);
final Object[] objects = new Object[] { token.getUser().getName(), title };
final String subject = messageSource.getMessage(MAIL_ACTIVATION, objects, locale);
final String confirmationUrl = String.format(Locale.ENGLISH, "%s/register/confirmation?token=%s", url, token.getKey());
MimeMailMessage mailMessage = new MimeMailMessage(mailSender.createMimeMessage());
mailMessage.setTo(recipientAddress);
mailMessage.setSubject(subject);
mailMessage.getMimeMessage().setFrom(new InternetAddress(address, title));
mailMessage.getMimeMessage().setContent(confirmationUrl, "text/html");
return mailMessage;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
Aggregations