zoukankan      html  css  js  c++  java
  • springboot常用功能

    1、常用注解

    2、邮件功能

    //依赖引入
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-mail</artifactId>
    </dependency>
    
    
    //邮件配置:application.yml 或者 application.properties
    spring.mail.host=smtp.qq.com
    spring.mail.username=用户名
    spring.mail.password=密码
    spring.mail.properties.mail.smtp.auth=true
    spring.mail.properties.mail.smtp.starttls.enable=true
    spring.mail.properties.mail.smtp.starttls.required=true
    
    
    @Test
    public void sendAttachmentsMail() throws Exception {
    
        MimeMessage mimeMessage = mailSender.createMimeMessage();
    
        MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
        helper.setFrom("123456@qq.com");
        helper.setTo("888888@qq.com");
        helper.setSubject("主题:我是一封有附件的邮件");
        helper.setText("有附件的邮件");
    
        FileSystemResource file = new FileSystemResource(new File("weixin.jpg"));
        helper.addAttachment("附件1.jpg", file);
        helper.addAttachment("附件2.jpg", file);
    
        mailSender.send(mimeMessage);
    }
  • 相关阅读:
    maven安装和四大特性
    rabbitMQ的安装和创建用户
    java小白之面向对象
    java初级笔记
    laravel 的升级
    prepare
    获取客户端真实IP
    apache nginx 区别
    七猫面试
    linux基本命令
  • 原文地址:https://www.cnblogs.com/chenweichu/p/13251517.html
Copyright © 2011-2022 走看看