首先要登陆outlook邮箱,点击设置滑到最下面选择完整设置

进入后选择邮件->同步电子邮件

打开pop如上设置

下面是我的application.propertis设置

请填上自己的邮箱名与密码,outlook邮箱目前不需要授权码,密码就是自己的邮箱密码

记得按下面开启tls验证,不然会显示匿名用户无法通过验证

 spring.mail.username=xxxxxxx@outlook.com
spring.mail.password=xxxxxxxxx
spring.mail.port=587
spring.mail.host=smtp-mail.outlook.com
# 设置ssl认证
# spring.mail.properties.mail.smtp.ssl.enable=true
# 设置TLS认证
spring.mail.properties.mail.smtp.starttls.required=true

下方是我的java代码:

setSubject是邮件标题
setText是邮件内容
setTo是发送给哪个邮箱
setFrom是从哪个邮箱发出
 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.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class)
@SpringBootTest
public class Springboot04TaskApplicationTests { @Autowired
JavaMailSenderImpl mailSender; @Test
public void contextLoads() {
SimpleMailMessage message = new SimpleMailMessage();
// 邮箱设置
message.setSubject("通知-程序测试");
message.setText("正在进行程序测试"); message.setTo("xxxxxx@163.com");
message.setFrom("xxxxxx@outlook.com"); mailSender.send(message);
} }

下面是pom文件:

 <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.atguigu</groupId>
<artifactId>springboot-04-task</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>springboot-04-task</name>
<description>Demo project for Spring Boot</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.15.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>

运行成功:

SpringBoot向outlook发送邮件的更多相关文章

  1. 使用C#模拟Outlook发送邮件,代码编译报错

    添加OutLook API using OutLook = Microsoft.Office.Interop.Outlook; 发送邮件方法 public void SendEmail() { Out ...

  2. VBS调用OUTLOOK发送邮件,windows计划任务定时拉起VBS调用OUTLOOK发送邮件

    OUTLOOK有延迟传递功能,可延迟传递的发送邮件在功能设计时(mircosoft的support帮助页的解释)就是邮件发送时的时间而不是邮件发送成功后的时间.比如早上10点发一封11点后的延迟传递邮 ...

  3. SpringBoot入门 (十) 发送邮件

    本文记录学习在SpringBoot中发送邮件. 一 邮件发送过程 发送邮件是一个我们在项目中经常会用到的功能,如在用户注册时发送验证码,账户激活等都会用到.完整的一个邮件发送过程主要包含以下几个步骤: ...

  4. SpringBoot整合ActiveMQ发送邮件

    虽然ActiveMQ以被其他MQ所替代,但仍有学习的意义,本文采用邮件发送的例子展示ActiveMQ 1. 生产者1.1 引入maven依赖1.2 application.yml配置1.3 创建配置类 ...

  5. SpringBoot整合Mail发送邮件&发送模板邮件

    整合mail发送邮件,其实就是通过代码来操作发送邮件的步骤,编辑收件人.邮件内容.邮件附件等等.通过邮件可以拓展出短信验证码.消息通知等业务. 一.pom文件引入依赖 <dependency&g ...

  6. SpringBoot开发六-发送邮件

    需求介绍-发送邮件 首先要进行邮箱设置,要启用客户端SMTP服务. 而且SpringBoot也给了JavaMailSender发送邮件. 代码实现 首先你需要设置好邮箱,步骤百度一大堆,记住要配置一个 ...

  7. C# 调用 Outlook发送邮件实例

    添加引用:Microsoft.Office.Interop.Outlook using System; using System.Collections.Generic; using System.L ...

  8. 170718、springboot编程之发送邮件

    Spring提供了非常好用的JavaMailSender接口实现邮件发送.在Spring Boot的Starter模块中也为此提供了自动化配置.下面通过实例看看如何在Spring Boot中使用Jav ...

  9. mailto web弹出outlook发送邮件

    1. <pre name="code" class="html"><a href="Mailto:test@163.com?CC=t ...

随机推荐

  1. Django——admin管理工具

    一.admin组件使用 Django 提供了基于 web 的管理工具. Django 自动管理工具是 django.contrib 的一部分.你可以在项目的 settings.py 中的 INSTAL ...

  2. vue学习笔记之基础篇

    本文主要记录学习vue的一些基础内容及常用知识点的记录. 1.搭建脚手架 vue init webpack vue-demo 初始化一个使用webpack打包的vue项目 npm install 安装 ...

  3. JavaScript中文拼音排序函数

    要对很多设备根据名称排序,找了找没有找到特别适合的,然后就自己写了一个根据中文拼音首字母排序的方法. github: https://github.com/haboll/sort.git

  4. SQL Server 2008 R2如何开启数据库的远程连接(转)

    SQL Server 2008默认是不允许远程连接的,如果想要在本地用SSMS连接远程服务器上的SQL Server 2008,远程连接数据库.需要做两个部分的配置: SQL Server Manag ...

  5. JSP初学者1

    native2ascii.exe 是 Java 的一个文件转码工具,是将特殊各异的内容 转为 用指定的编码标准文体形式统一的表现出来,它通常位于 JDK_home\bin 目录下, 安装好 Java ...

  6. 管理uWSGI服务器

    管理uWSGI服务器 官网参考 如果您正在管理多个应用程序或高容量站点,请查看 uwsgi皇帝-多应用程序部署 虫族模式 UWSGI订阅式服务器 启动uwsgi服务器 以系统管理员身份启动 uwsgi ...

  7. haproxy学习——简介、基本配置(二)

    官网:http://www.haproxy.org/ 个人感觉haproxy学习的重点在于配置上,把配置文档搞懂了就明白大部分套路了.不过本篇内容属于入门学习:1.使用haproxy简单的实现负载均衡 ...

  8. 屏幕  z

    private   void   FullScreen()   //全屏      {      SizeMode   =   2;      FormBorderStyle   =   FormBo ...

  9. python常用模块(一)

    #什么是模块呢?就是用一大坨代码来完成一个功能的代码集合,是不是简单易懂 #类似于函数式编程和面向过程编程,函数式编程则完成一个功能,其他代码用来调用即可,提供了代码的重用性和代码间的耦合.而对于一个 ...

  10. 关于simotion建立同步/解除同步的问题

    关于simotion建立同步/解除同步的问题. 问题: [enable gearing][disable gearing][enable camming][disable camming]都是一个过程 ...