v1.0.0
Release v1.0.0
Welcome to version 1.0.0 of the Proofpoint Secure Email Relay Mail API Java Library.
Key Changes
Immutability:
- All core classes (Message, Attachment, Content, MailUser, MessageHeaders) are now immutable.
- Fields are final, setters have been removed, and state cannot be modified after construction.
- Ensures thread-safety and predictable behavior in concurrent or distributed systems.
Fluent Builder Pattern: - Replaced traditional constructors and setters with builder patterns for all classes.
- Message.Builder enforces build-time validation for required fields: from, to, subject, and content.
Example:
Message message = Message.builder()
.subject("Test")
.from("sender@example.com")
.addTo("recipient@example.com")
.addContent("Hello", Content.ContentType.TEXT)
.build();New Features
-
Fluent Builder Pattern:
- Added a
Message.Builderclass for constructingMessageobjects with a chainable API. - Enforces build-time validation for required fields:
from,to,subject, andcontent. - Example:
Message.builder().subject("Test").from(sender).addTo(recipient).addContent(content).build().
- Added a
-
Attachment Support:
- Attach files from disk (
fromFile), Base64-encoded strings (fromBase64), or byte arrays (fromBytes). - Auto-deduces MIME types based on file extensions, with options to override.
- Attach files from disk (
-
Inline Attachments with Content-IDs:
- Supports inline attachments via
dispositionInline()with manual or auto-generated content IDs. - Example:
<img src="cid:logo">withAttachment.builder().fromFile("logo.png").dispositionInline("logo").build().
- Supports inline attachments via
-
HTML & Plain Text Content:
- Seamlessly add both plain text and HTML content bodies via the builder.
-
Recipient & Reply Management:
- Fluent methods for
To,CC,BCC, andReply-Torecipients (e.g.,.addTo(),.addCc(),.addReplyTo()).
- Fluent methods for
-
Concurrency Support:
- Thread-safe
Clientfor concurrent email sending using thread pools.
- Thread-safe
-
OAuth Authentication:
- Integrated with
OAuthHttpClientfor secure API access using client credentials.
- Integrated with
Removed
This release establishes a modern, immutable API, removing legacy construction methods and setters:
Traditional Constructors:
Message(String subject, MailUser from)Message(String subject, MailUser from, MailUser headerFrom)
Replaced with Message.builder() for validated, fluent construction.
Legacy Setters:
Message.setHeaderFrom(MailUser)Message.addAttachment(Attachment)Message.addContent(Content)Message.addTo(MailUser)Message.addCc(MailUser)Message.addBcc(MailUser)Message.addReplyTo(MailUser)
Use equivalent Message.Builder methods (e.g., .addContent()).
Mutable State:
- Removed all setters across
Message,Attachment,Content,MailUser, andMessageHeaders.
Use builders to construct immutable instances (e.g., Content via constructor, Attachment via step builder).
Quick Start
import io.pfpt.ser.mail.*;
public class Example {
public static void main(String[] args) {
Client client = new Client("<client_id>", "<client_secret>");
Message message = Message.builder()
.subject("This is a test email")
.from("sender@example.com", "Joe Sender")
.addContent("This is a test message", Content.ContentType.TEXT)
.addTo("recipient1@example.com", "Recipient 1")
.build();
SendResult sendResult = client.send(message).join();
System.out.println("HTTP Status: " + sendResult.getHttpResponse().statusCode());
}
}Full Changelog: v0.0.1...v1.0.0