一、注册新浪邮箱

1.1选择设置

1.2对邮箱设置进行设置

二.idea中操作

2.1引入mail依赖

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-mail</artifactId><version>2.1.5.RELEASE</version></dependency>

2.2编写配置文件

# MailProperties
spring.mail.host=smtp.sina.com
spring.mail.username=自己的邮箱用户民
spring.mail.password=授权码(自己的邮箱)
spring.mail.properties.mail.smtl.auth=true
spring.mail.properties.mail.stmp.starttls.enable=true
spring.mail.properties.mail.stmp.starttls.required=true

2.3mail的工具类

package com.nowcoder.community.util;import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;@Component
public class MailClient {private static final Logger logger = LoggerFactory.getLogger(MailClient.class);@Autowiredprivate JavaMailSender mailSender;@Value("${spring.mail.username}")private String from;public void sendMail(String to, String subject, String content) {try {MimeMessage message = mailSender.createMimeMessage();MimeMessageHelper helper = new MimeMessageHelper(message);helper.setFrom(from);helper.setTo(to);helper.setSubject(subject);helper.setText(content, true);mailSender.send(helper.getMimeMessage());} catch (MessagingException e) {logger.error("发送邮件失败:" + e.getMessage());}}}

2.4编写测试类

package com.nowcoder.community;import com.nowcoder.community.util.MailClient;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration(classes = CommunityApplication.class)
public class MailTests {@Autowiredprivate MailClient mailClient;@Autowiredprivate TemplateEngine templateEngine;@Testpublic void testTextMail() {mailClient.sendMail("填写邮箱即可", "TEST", "Welcome.");}}

邮箱功能开发总结(以新浪邮箱为例子)相关推荐

  1. 网易邮箱申请多少钱、新浪邮箱多少钱、TOM VIP呢?

    网易邮箱申请多少钱?新浪邮箱多少钱?TOMVIP多少钱?VIP邮箱应该如何选择?今天小编就帮大家介绍下国内三大邮箱的价格. 一.TOM VIP邮箱 网易邮箱申请多少钱.阿里邮箱多少钱.TOM VIP呢 ...

  2. web开发(九) 使用javamail进行发送邮件,(使用QQ,163,新浪邮箱服务器)

    在网上看见一篇不错的文章,写的详细. 以下内容引用那篇博文.转载于<http://www.cnblogs.com/whgk/p/6506027.html>,在此仅供学习参考之用. 一.发送 ...

  3. Linux上的服务器无法调用新浪邮箱发送邮件

    问题背景: 在web网站开发中,有许多功能的实现需要发送邮件,比如用户的密码找回功能,可能就需要通过服务器向用户的注册邮箱发送验证码邮件来实现.而发送邮件功能可以通过很多方式实现,比如HTML中的ma ...

  4. 破解sina新浪邮箱密码

    这里我们采用sina新浪邮箱密码破解工具进行破解.关于QQ,微信,网络等问题可加技术人员QQ.616 99 58.邮箱密码破解工具是邮箱密码破解软件.破解器的统称.我们选择新浪邮箱密码破解工具好了,现 ...

  5. html注册新浪邮箱代码,JS仿新浪邮箱点击联系人添加Email地址

    新浪邮箱添加功能 var ev={}; var flyDiv="bxAddrFly"; var inceptDiv="SendAddress"; var add ...

  6. flask 发送新浪邮箱邮件

    邮件的用处很多,如注册时验证用户.找回密码.线上程序出现重大bug时触发邮件提醒以及服务器关键数据(CPU.网络.内存)监控提醒等 安装使用邮件的依赖包 pip install Flask-Mail ...

  7. 新浪邮箱SMTP开启

    codeblocks 逐个创建c程序,每个程序都创建一个独立的工程, c程序编译报错,可以反复编译,一旦编译完成,谨慎再次编译.但可以随意运行.  c程序头文件stdio.h,  c++头文件iost ...

  8. js提取新浪邮箱的信用卡

    js提取用户新浪邮箱中的信用卡信息,是js非nodejs. 对比py,之前就做不好,出现了复杂点选验证码.js的开发速度只需要py的三分之一,甚至十分之一. js在客户端执行,py在后端执行,py要实 ...

  9. 新浪邮箱发信php源码,Winmail退信分析大全

    退信示例 Hi, Your message can not deliver to the following addresses. Error information: , remote server ...

最新文章

  1. linux不识别ntfs分区,WinUbuntu下linux无法挂载NTFS格式分区问题的解决
  2. 基于JavaWeb实现网上花店商城系统
  3. 2020下半年新机最新消息_2020年下半年即将发布的手机,你们期待吗
  4. python3.7安装numpy模块-Python3.7模块numpy
  5. matlab验证Ross随机过程(第二版)P19页的结果
  6. OD使用教程20 - 调试篇20
  7. 设计模式13_享元模式
  8. 浅谈 Run-Time Check Failure #2 - Stack around the variable 'xxx' was corrupted 的解决方法
  9. 突变注释工具SnpEff,Annovar,VEP,oncotator比较分析--转载
  10. 2014-10-18 多玩初面
  11. 学习《华为基本法》(9):预算控制和成本控制
  12. 欧拉角到方向余弦矩阵
  13. ZZULIOJ 1196: 数星星(二)(结构体专题)
  14. 关于Android的post,get、cookie网络获取的一些坑
  15. 【小米商城-1 注册功能】
  16. 带你玩东方系列(视频版)游戏链接
  17. Python学习十:网络编程
  18. 固态硬盘数据恢复商家梳理
  19. python批量下载网页图片,不用再复制粘贴了(7)
  20. CDateTimeCtrl 用法总结

热门文章

  1. 数据结构单链表插入和删除操作
  2. oracle nvl()和nvl2()
  3. 三星Galaxy s4(i9505)完美获取root权限教程
  4. 转自IBM学习 浅析 Linux 初始化 init 系统,第 3 部分 Systemd
  5. 封装前端UI组件库--button
  6. redux-thunk-基本使用
  7. Java培训机构哪家好,不靠谱的有哪些
  8. 同惠TH9310耐压测试仪应用举例
  9. NSIS:迅雷5.8.6.600自由定制版脚本及下载
  10. 修身养性,为人处事100条