使用Javax.mail 发送邮件
使用Javax.mail 发送邮件
详细说明都在代码中:
-
引入依赖
<!--sun定义的一套接收、发送电子邮件的API-->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
-
编写代码
package com.joyful.demo.service;
import org.springframework.stereotype.Service;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.Date;
import java.util.Properties;