邮件发送

1、配置文件

  1. 文件位置:dodo_framework_config.properties
  2. dodo.mailsender.smtpHost=smtp.exmail.qq.com
  3. dodo.mailsender.smtpPort=25
  4. dodo.mailsender.smtpUsername=admin@bydodo.com
  5. dodo.mailsender.smtpPassword=123456
  6. dodo.mailsender.smtpCompanyName=Dodo Framework
  7. dodo.mailsender.smtpFromMail=admin@bydodo.com

2、使用

  1. //依赖注入MailService,然后使用提供的方法
  2. @Autowired
  3. private MailService mailService;

3、MailService

  1. public interface MailService {
  2. // 单人发送模板邮件
  3. void sendMail(String subject, String templateFilePath, Map<String, Object> data, String toMail)
  4. throws TemplateException, MessagingException, IOException;
  5. // 单人发送邮件
  6. void sendMail(String subject, String msgContent, String toMail) throws MessagingException,
  7. UnsupportedEncodingException;
  8. // 多人发送模板邮件
  9. void sendMail(String subject, String templateFilePath, Map<String, Object> data, String[] toMail)
  10. throws IOException, TemplateException, MessagingException;
  11. // 多人发送邮件
  12. void sendMail(String subject, String msgContent, String[] toMail) throws MessagingException,
  13. UnsupportedEncodingException;
  14. }