Class Email.Builder
java.lang.Object
cloud.opencode.base.email.Email.Builder
- Enclosing class:
Email
Email Builder
邮件构建器
- Since:
- JDK 25, opencode-base-email V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionattach(Attachment attachment) Add attachment 添加附件Add file attachment 添加文件附件attachAll(Collection<Attachment> attachments) Add multiple attachments 添加多个附件Add BCC recipient email addresses 添加密送收件人邮箱地址bcc(Collection<String> addresses) Add BCC recipient email addresses from collection 从集合添加密送收件人邮箱地址build()Build the email 构建邮件Add CC recipient email addresses 添加抄送收件人邮箱地址cc(Collection<String> addresses) Add CC recipient email addresses from collection 从集合添加抄送收件人邮箱地址Set sender email address 设置发件人邮箱地址Set sender email address with display name 设置发件人邮箱地址和显示名称Add custom header 添加自定义邮件头Add multiple custom headers 添加多个自定义邮件头Set HTML content 设置HTML内容priority(Email.Priority priority) Set email priority 设置邮件优先级Set reply-to address 设置回复地址Set email subject 设置邮件主题Set plain text content 设置纯文本内容textAndHtml(String text, String htmlContent) Set both plain text and HTML content (multipart/alternative) 同时设置纯文本和HTML内容(multipart/alternative)Add recipient email addresses 添加收件人邮箱地址to(Collection<String> addresses) Add recipient email addresses from collection 从集合添加收件人邮箱地址
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
from
Set sender email address 设置发件人邮箱地址- Parameters:
from- the sender email | 发件人邮箱- Returns:
- this builder | 构建器
-
from
Set sender email address with display name 设置发件人邮箱地址和显示名称- Parameters:
from- the sender email | 发件人邮箱name- the display name | 显示名称- Returns:
- this builder | 构建器
-
to
Add recipient email addresses 添加收件人邮箱地址- Parameters:
addresses- the recipient emails | 收件人邮箱- Returns:
- this builder | 构建器
-
to
Add recipient email addresses from collection 从集合添加收件人邮箱地址- Parameters:
addresses- the recipient emails | 收件人邮箱- Returns:
- this builder | 构建器
-
cc
Add CC recipient email addresses 添加抄送收件人邮箱地址- Parameters:
addresses- the CC emails | 抄送邮箱- Returns:
- this builder | 构建器
-
cc
Add CC recipient email addresses from collection 从集合添加抄送收件人邮箱地址- Parameters:
addresses- the CC emails | 抄送邮箱- Returns:
- this builder | 构建器
-
bcc
Add BCC recipient email addresses 添加密送收件人邮箱地址- Parameters:
addresses- the BCC emails | 密送邮箱- Returns:
- this builder | 构建器
-
bcc
Add BCC recipient email addresses from collection 从集合添加密送收件人邮箱地址- Parameters:
addresses- the BCC emails | 密送邮箱- Returns:
- this builder | 构建器
-
subject
Set email subject 设置邮件主题- Parameters:
subject- the subject | 主题- Returns:
- this builder | 构建器
-
text
Set plain text content 设置纯文本内容- Parameters:
content- the text content | 文本内容- Returns:
- this builder | 构建器
-
html
Set HTML content 设置HTML内容- Parameters:
content- the HTML content | HTML内容- Returns:
- this builder | 构建器
-
textAndHtml
Set both plain text and HTML content (multipart/alternative) 同时设置纯文本和HTML内容(multipart/alternative)The email client will choose the best format to display. HTML-capable clients show HTML, plain text clients show text.
邮件客户端会选择最佳格式显示。支持HTML的客户端显示HTML,纯文本客户端显示文本。
- Parameters:
text- the plain text content | 纯文本内容htmlContent- the HTML content | HTML内容- Returns:
- this builder | 构建器
-
attach
Add attachment 添加附件- Parameters:
attachment- the attachment | 附件- Returns:
- this builder | 构建器
-
attach
Add file attachment 添加文件附件- Parameters:
file- the file path | 文件路径- Returns:
- this builder | 构建器
-
attachAll
Add multiple attachments 添加多个附件- Parameters:
attachments- the attachments | 附件列表- Returns:
- this builder | 构建器
-
header
Add custom header 添加自定义邮件头- Parameters:
name- the header name | 邮件头名称value- the header value | 邮件头值- Returns:
- this builder | 构建器
-
headers
Add multiple custom headers 添加多个自定义邮件头- Parameters:
headers- the headers | 邮件头- Returns:
- this builder | 构建器
-
replyTo
Set reply-to address 设置回复地址- Parameters:
replyTo- the reply-to email | 回复邮箱- Returns:
- this builder | 构建器
-
priority
Set email priority 设置邮件优先级- Parameters:
priority- the priority | 优先级- Returns:
- this builder | 构建器
-
build
Build the email 构建邮件- Returns:
- the email | 邮件
- Throws:
EmailException- if validation fails | 验证失败时抛出
-