JavaMailSender怎么发送163和qq邮件
https://blog.csdn.net/Tracycater/article/details/73441010
引入Maven依赖包
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-mail</artifactId>
</dependency>
1
2
3
4
163邮箱
application.properties
#####163邮箱########
spring.mail.host=smtp.163.com
spring.mail.username=*****@163.com
#163邮箱密码
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
1
2
3
4
5
6
7
8
运行类:
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes=Application.class)
public class My163MailTest {
@Autowired
    private JavaMailSender javaMailSender;
@Value("${spring.mail.username}")
    private String username;
@Test
    public void testSendSimple() {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(username);
        message.setTo("*******@qq.com");
        message.setSubject("标题:测试标题");
        message.setText("测试内容部份");
        javaMailSender.send(message);
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
QQ邮箱和163邮箱的区别是需要设置授权码而不是密码,具体操作参考: 
http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=1001256
application.properties
######qq邮箱########
spring.mail.host=smtp.qq.com
spring.mail.username=******@qq.com
#QQ邮箱授权码
spring.mail.password=xuojxtkdojvzbhjj
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
1
2
3
4
5
6
7
8
运行类:
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes=Application.class)
public class MyQQMailTest {
@Autowired
    private JavaMailSender javaMailSender;
@Value("${spring.mail.username}")
    private String username;
@Test
    public void testSendSimple() {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(username);
        message.setTo("******@qq.com");
        message.setSubject("标题:测试标题");
        message.setText("测试内容部份");
        javaMailSender.send(message);
    }
}
--------------------- 
作者:罗罗诺亚-小鱼 
来源:CSDN 
原文:https://blog.csdn.net/Tracycater/article/details/73441010 
版权声明:本文为博主原创文章,转载请附上博文链接!
JavaMailSender怎么发送163和qq邮件的更多相关文章
- 使用python发送163邮件 qq邮箱
		
使用python发送163邮件 def send_email(title, content): import smtplib from email.mime.multipart import MIME ...
 - spring boot:发送带附件的邮件和html内容的邮件(以163.com邮箱为例/spring boot 2.3.2)
		
一,网站哪些情况下需要发送电子邮件? 作为一个电商网站,以下情况需要发邮件通知用户: 注册成功的信息 用邮箱接收验证码 找回密码时发链接 发送推广邮件 下单成功后的订单通知 给商户的对账单邮件 说明: ...
 - 5分钟 wamp下php phpmaile发送qq邮件 2015最新方法说明
		
13:40 2015/11/20 5分钟 wamp下php phpmaile发送qq邮件 2015最新方法说明 关键点:现在qq邮箱开通smtp服务后会给你一个很长的独立新密码,发邮件配置中的密码需要 ...
 - java代码如何发送QQ邮件
		
近来想写一个qq之间互相发送邮件的工具.奈何一直报错服务错误: org.apache.commons.mail.EmailException: Sending the email to the fol ...
 - 利用Python+163邮箱授权码发送带附件的邮件
		
背景 前段时间写了个自动爬虫的脚本,定时在阿里云服务器上执行,会从某个网站上爬取链接保存到txt文本中,但是脚本不够完善,我需要爬虫完毕之后通过邮件把附件给我发送过来,之前写过一个<利用Pyth ...
 - flask_mail发送163邮件,报553错误的原因
		
最近在练习用flask_mail发送163邮件时报错: reply: '553 authentication is required,163 smtp9,DcCowAD3eEQZ561caRiaBA- ...
 - 【python】脚本连续发送QQ邮件
		
今天习得用python写一个连续发送QQ邮件的脚本,经过测试,成功给国内外的服务器发送邮件,包括QQ邮箱.163邮箱.google邮箱,香港科技大学的邮箱和爱丁堡大学的邮箱.一下逐步解答相关技巧. 首 ...
 - C#发送QQ邮件
		
1.首先配置一下发件人的账号密码(密码根据自己所选择的的邮箱填写,此处不做展示) <?xml version="1.0" encoding="utf-8" ...
 - python 发送QQ邮件的小例子
		
首先QQ邮件用第三方客户端发送要申请验证码.而不是QQ的密码. 授权码就是你接下来登录要使用的密码 那么剩下的工作就很简单了.附简单代码如下: #coding:utf-8 import smtplib ...
 
随机推荐
- 实用jQuery代码片段
			
maco精选的一些jQuery代码,也许你从中可以举一反三[代码] [JavaScript]代码001<p>002 <h3><span >★ 使用jQuery ...
 - BluetoothLE-Multi-Library  一个能够连接多台蓝牙设备的库,它可以作为client端,也可以为server端。支持主机/从机,外围设备连接。
			
github地址:https://github.com/qindachang/BluetoothLE-Multi-Library BluetoothLE-Multi-Library 一个能够连接多台蓝 ...
 - JDBC 笔记3 通过PreparedStatement 对数据库进行增删改查 (转载)
			
之前MVC时一直用它,学了框架后就没怎么用了.这里转载一位同学的博客,以后可能也会用到的. 转自:https://www.cnblogs.com/zilong882008/archive/2011/1 ...
 - hdu-2157 How many ways??(矩阵快速幂)
			
题目链接: How many ways?? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
 - 修改SO
			
1.如果在jni中定义的是int型的数据,比如: JNIEXPORT jint JNICALL Java_com_ggndktest1_JniGg_getCoin (JNIEnv * env, job ...
 - w3C盒子模型和IE的盒子模型
			
W3C 盒子模型的范围包括 margin.border.padding.content,并且 content 部分不包含其他部分IE 盒子模型的范围也包括 margin.border.padding. ...
 - AutoIt with XML: Add a child/grandchild node or remove any node
			
Sometimes, we have to use AutoIt script to edit an xml, add a node or remove a node, to make some de ...
 - 深度学习网络结构中超参数momentum了解
			
训练网络时,通常先对网络的初始权值按照某种分布进行初始化,如:高斯分布.初始化权值操作对最终网络的性能影响比较大,合适的网络初始权值能够使得损失函数在训练过程中的收敛速度更快,从而获得更好的优化结果. ...
 - MSTAR SETBOX 常用API
			
HASHKEY: HashKey需要替换两个文件:“Customer_info.h”与“libecos.a” 1.MApi_DigiTuner_TPSGetLock() //判断是否有信号 2._Za ...
 - socket服务器并发处理
			
我们知道,服务器通常是要同时服务多个客户端的,如果我们运行上一篇实现的server和client之后,再开一个终端运行client试试,新的client就不能能得到服务了.因为服务器之支持一个连接. ...