Package | Description |
---|---|
cn.hutool.extra.mail |
邮件封装,基于javax-mail库,入口为MailUtil
|
Modifier and Type | Method and Description |
---|---|
MailAccount |
MailAccount.defaultIfEmpty()
如果某些值为null,使用默认值
|
MailAccount |
GlobalMailAccount.getAccount()
获得邮件帐户
|
MailAccount |
MailAccount.setAuth(boolean isAuth)
设置是否需要用户名密码验证
|
MailAccount |
MailAccount.setCharset(Charset charset)
设置字符集编码,此选项不会修改全局配置,若修改全局配置,请设置此项为
null 并设置:
System.setProperty("mail.mime.charset", charset);
|
MailAccount |
MailAccount.setConnectionTimeout(long connectionTimeout)
设置Socket连接超时值,单位毫秒,缺省值不超时
|
MailAccount |
MailAccount.setCustomProperty(String key,
Object value)
设置自定义属性,如mail.smtp.ssl.socketFactory
|
MailAccount |
MailAccount.setDebug(boolean debug)
设置是否打开调试模式,调试模式会显示与邮件服务器通信过程,默认不开启
|
MailAccount |
MailAccount.setFrom(String from)
设置发送方,遵循RFC-822标准
发件人可以是以下形式: 1. user@xxx.xx 2. |
MailAccount |
MailAccount.setHost(String host)
设置SMTP服务器域名
|
MailAccount |
MailAccount.setPass(String pass)
设置密码
|
MailAccount |
MailAccount.setPort(Integer port)
设置SMTP服务端口
|
MailAccount |
MailAccount.setSocketFactoryClass(String socketFactoryClass)
设置指定实现javax.net.SocketFactory接口的类的名称,这个类将被用于创建SMTP的套接字
|
MailAccount |
MailAccount.setSocketFactoryFallback(boolean socketFactoryFallback)
如果设置为true,未能创建一个套接字使用指定的套接字工厂类将导致使用java.net.Socket创建的套接字类, 默认值为true
|
MailAccount |
MailAccount.setSocketFactoryPort(int socketFactoryPort)
指定的端口连接到在使用指定的套接字工厂。
|
MailAccount |
MailAccount.setSslEnable(Boolean sslEnable)
设置是否使用SSL安全连接
|
MailAccount |
MailAccount.setStarttlsEnable(boolean startttlsEnable)
设置是否使用STARTTLS安全连接,STARTTLS是对纯文本通信协议的扩展。
|
MailAccount |
MailAccount.setTimeout(long timeout)
设置SMTP超时时长,单位毫秒,缺省值不超时
|
MailAccount |
MailAccount.setUser(String user)
设置用户名
|
MailAccount |
MailAccount.setWriteTimeout(long writeTimeout)
设置Socket写出超时值,单位毫秒,缺省值不超时
|
Modifier and Type | Method and Description |
---|---|
static Mail |
Mail.create(MailAccount mailAccount)
创建邮件客户端
|
static JakartaMail |
JakartaMail.create(MailAccount mailAccount)
创建邮件客户端
|
static javax.mail.Session |
MailUtil.getSession(MailAccount mailAccount,
boolean isSingleton)
根据配置文件,获取邮件客户端会话
|
static jakarta.mail.Session |
JakartaMailUtil.getSession(MailAccount mailAccount,
boolean isSingleton)
根据配置文件,获取邮件客户端会话
|
static String |
MailUtil.send(MailAccount mailAccount,
Collection<String> tos,
Collection<String> ccs,
Collection<String> bccs,
String subject,
String content,
boolean isHtml,
File... files)
发送邮件给多人
|
static String |
JakartaMailUtil.send(MailAccount mailAccount,
Collection<String> tos,
Collection<String> ccs,
Collection<String> bccs,
String subject,
String content,
boolean isHtml,
File... files)
发送邮件给多人
|
static String |
MailUtil.send(MailAccount mailAccount,
Collection<String> tos,
Collection<String> ccs,
Collection<String> bccs,
String subject,
String content,
Map<String,InputStream> imageMap,
boolean isHtml,
File... files)
发送邮件给多人
|
static String |
JakartaMailUtil.send(MailAccount mailAccount,
Collection<String> tos,
Collection<String> ccs,
Collection<String> bccs,
String subject,
String content,
Map<String,InputStream> imageMap,
boolean isHtml,
File... files)
发送邮件给多人
|
static String |
MailUtil.send(MailAccount mailAccount,
Collection<String> tos,
String subject,
String content,
boolean isHtml,
File... files)
发送邮件给多人
|
static String |
JakartaMailUtil.send(MailAccount mailAccount,
Collection<String> tos,
String subject,
String content,
boolean isHtml,
File... files)
发送邮件给多人
|
static String |
MailUtil.send(MailAccount mailAccount,
Collection<String> tos,
String subject,
String content,
Map<String,InputStream> imageMap,
boolean isHtml,
File... files)
发送邮件给多人
|
static String |
JakartaMailUtil.send(MailAccount mailAccount,
Collection<String> tos,
String subject,
String content,
Map<String,InputStream> imageMap,
boolean isHtml,
File... files)
发送邮件给多人
|
static String |
MailUtil.send(MailAccount mailAccount,
String to,
String subject,
String content,
boolean isHtml,
File... files)
发送邮件给多人
|
static String |
JakartaMailUtil.send(MailAccount mailAccount,
String to,
String subject,
String content,
boolean isHtml,
File... files)
发送邮件给多人
|
static String |
MailUtil.send(MailAccount mailAccount,
String to,
String subject,
String content,
Map<String,InputStream> imageMap,
boolean isHtml,
File... files)
发送邮件给多人
|
static String |
JakartaMailUtil.send(MailAccount mailAccount,
String to,
String subject,
String content,
Map<String,InputStream> imageMap,
boolean isHtml,
File... files)
发送邮件给多人
|
Constructor and Description |
---|
JakartaMail(MailAccount mailAccount)
构造
|
Mail(MailAccount mailAccount)
构造
|
Copyright © 2024. All rights reserved.