Beispiel #1
0
  public void sendMail(Email email) throws MessagingException {
    MimeMessage message = mailSender.createMimeMessage();

    MimeMessageHelper messageHelper = new MimeMessageHelper(message, true, "UTF-8");
    messageHelper.setSubject(email.getSubject());
    messageHelper.setTo(email.getReceiver());
    messageHelper.setFrom(sender);
    messageHelper.setText(email.getContent(), true);
    mailSender.send(message);
  }
  @Override
  public void send(Email email) {
    Message message = createMessage();
    try {
      message.setSubject(email.getSubject());
      message.setContent(email.getContent(), "text/html;charset=utf-8");

      message.setRecipients(Message.RecipientType.TO, toAddress(email.getTo()));
      message.setRecipients(Message.RecipientType.CC, toAddress(email.getCc()));

      Transport.send(message);
    } catch (MessagingException e) {
      logger.error("InstallUtils executeSQL erro", e);
    }
  }