# QQ邮件提醒 **Repository Path**: bear_shi_wu/qq_mail ## Basic Information - **Project Name**: QQ邮件提醒 - **Description**: 记载自己的第二天或者将要做的事儿 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 0 - **Created**: 2020-12-21 - **Last Updated**: 2022-11-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # QQ邮件提醒健康打卡 #### 介绍 记载自己的第二天或者将要做的事儿,比如现在的健康打卡 #### 软件架构 软件架构说明 #### 安装教程 1. 创建一个spring boot项目(略) 2. 安装以下依赖: ``` org.quartz-scheduler quartz-jobs 2.3.2 org.springframework.boot spring-boot-starter-mail ``` 3. 创建service接口 ``` void sendMail(String[] to, String subject, String content, String images); ``` 4. 实现service接口 ``` @Override public void sendMail(String[] to, String subject, String content) throws MessagingException { MimeMessage mimeMessage = javaMailSender.createMimeMessage(); // 设置utf-8或GBK编码,否则邮件会有乱码,true表示为multipart邮件 MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true, "utf-8"); // 邮件标题 helper.setSubject(subject); //内容,可以用html设置样式,但是必须是true,默认是false helper.setText("

" + content + "

", true); //附件,filename:在邮件中展示附件的名字,filepath在当前机器中的路径 helper.setFrom(sender); // 邮件接收地址 helper.setTo(to); javaMailSender.send(mimeMessage); } ``` 5. 配置application.yml文件 ``` spring: mail: # 163 host: smtp.qq.com port: username: xshiwu@qq.com password: xxxxxxxx protocol: smtp default-encoding: UTF-8 properties: mail.smtp.auth: true mail.smtp.starttls.enable: true mail.smtp.starttls.required: true mail.smtp.socketFactory.port: 465 mail.smtp.socketFactory.class: javax.net.ssl.SSLSocketFactory mail.smtp.socketFactory.fallback: false to: # 发送人的QQ邮箱 sender: xshiwu@qq.com # 接受的邮箱 qq: 2385756401@qq.com # 邮箱标题 title: 健康打卡 # 邮箱内容 content: 请前往企业微信进行健康打卡 # 附加图片 # images: # 附件文件 # filePath: ``` #### 使用说明 1. 克隆项目以后更改yml中的username以及password即可,password在QQ邮箱里面开启SMTP后复制过来 2. to.qq是数组形式,多个QQ用逗号隔开 #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)