Maven依赖:
邮件发送步骤
` import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.extra.mail.MailAccount;
import cn.hutool.extra.mail.MailUtil;
import java.util.ArrayList;
public class Email {
public Email()
{ //1、设置邮件账号
_MailAccount mailAccount= new MailAccount();
mailAccount.setHost(“smtp.qq.com”);
mailAccount.setPort(587);
mailAccount.setAuth(true);
mailAccount.setFrom(“发送方QQ号@qq.com”);
mailAccount.setUser(“发送方QQ号”);
mailAccount.setPass(“发送方QQ邮箱授权码”);
//1、单个发邮件
MailUtil._send( “mailAccount,接收方邮件地址”, “标题 “, “内容”, false:是否为html);
//2、群发
// 群发对象
_ArrayList lists= CollUtil._newArrayList(“接收方邮件地址1”,“接收方邮件地址2”);
MailUtil.send(mailAccount, 接收对象列表, “标题”, “内容”, false);
_//带文件和附件<br /> _MailUtil._send_(mailAccount, lists, **"html内容和附件"**, **"<a>https://www.iteye.com/blog/zwm2018-2439833</a>"**,**true**, FileUtil._file_(**"D:\\image\\images\\b0.png"**):附件);
}
}
`