类 EmailUtil

java.lang.Object
cn.warpin.core.config.EmailUtil

@Component public class EmailUtil extends Object
  • 字段详细资料

    • fromMail

      @Value("${spring.mail.from}") private String fromMail
    • host

      @Value("${spring.mail.host}") private String host
    • port

      @Value("${spring.mail.port}") private String port
    • mailSender

      private org.springframework.mail.javamail.JavaMailSender mailSender
  • 构造器详细资料

    • EmailUtil

      public EmailUtil()
  • 方法详细资料

    • sendMessage

      public void sendMessage(String from, String pwd, String to, String subject, String content)
      发送纯文本邮件信息
      参数:
      from - 发送方
      to - 接收方
      subject - 邮件主题
      content - 邮件内容(发送内容)
    • sendMessage

      public void sendMessage(String to, String subject, String content)
      使用默认邮箱发送
      参数:
      to -
      subject -
      content -
    • sendMessageCarryFiles

      public void sendMessageCarryFiles(String to, String subject, String content, File[] files)
      发送带附件的邮件信息
      参数:
      to - 接收方
      subject - 邮件主题
      content - 邮件内容(发送内容)
      files - 文件数组 // 可发送多个附件
    • sendMessageCarryFile

      public void sendMessageCarryFile(String to, String subject, String content, File file)
      发送带附件的邮件信息
      参数:
      to - 接收方
      subject - 邮件主题
      content - 邮件内容(发送内容)
      file - 单个文件
    • sendMessageCarryUrlAttachment

      public void sendMessageCarryUrlAttachment(String to, String subject, String content, String fileUrl)
      发送带附件的邮件信息 URL url = new URI(encodeUrl(fileUrl)).toURL();
      参数:
      to -
      subject -
      content -
      fileUrl -
    • getMailSender

      public org.springframework.mail.javamail.JavaMailSenderImpl getMailSender(String userName, String password)
    • encodeUrl

      public String encodeUrl(String fileUrl) throws URISyntaxException
      抛出:
      URISyntaxException
    • getFileExtension

      private String getFileExtension(String fileName)