@Test public void testTemplateEmailTest() throws MessagingException { Context context = new Context(); context.setVariable("username", "张三"); context.setVariable("id", "2667395"); String emailContent = templateEngine.process("emailTemplate", context); mailService.sendHtmlMail(to, "发送模板邮件", emailContent); }
public void sendHtmlMail(String to, String subject, String content) throws MessagingException { MimeMessage message = javaMailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true); helper.setFrom(from); helper.setTo(to); helper.setSubject(subject); helper.setText(content, true); javaMailSender.send(message); }
MailService { public void sendHtmlMail(String to, String subject, String content) throws MessagingException { MimeMessage message = javaMailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true); helper.setFrom(from); helper.setTo(to); helper.setSubject(subject); helper.setText(content, true); javaMailSender.send(message); } }
MailService { public void sendHtmlMail(String to, String subject, String content) throws MessagingException { MimeMessage message = javaMailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true); helper.setFrom(from); helper.setTo(to); helper.setSubject(subject); helper.setText(content, true); javaMailSender.send(message); }  }
MailService { public void sendHtmlMail(String to, String subject, String content) throws MessagingException { MimeMessage message = javaMailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true); helper.setFrom(from); helper.setTo(to); helper.setSubject(subject); helper.setText(content, true); javaMailSender.send(message); }  void sendTextMail(String to, String subject, String content); void sendHtmlMail(String to, String subject, String content); void sendAttachmentMail(String to, String subject, String content, String[] filePathList); void sendHtmlInlinePhotoMail(String to, String subject, String content, String srcPath, String srcId); }
MailService { public void sendHtmlMail(String to, String subject, String content) throws MessagingException { MimeMessage message = javaMailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true); helper.setFrom(from); helper.setTo(to); helper.setSubject(subject); helper.setText(content, true); javaMailSender.send(message); }  void sendTextMail(String to, String subject, String content); void sendHtmlMail(String to, String subject, String content); void sendAttachmentMail(String to, String subject, String content, String[] filePathList); void sendHtmlInlinePhotoMail(String to, String subject, String content, String srcPath, String srcId);  }