Skip to content

v1.0.0

Choose a tag to compare

@ludvikjerabek ludvikjerabek released this 28 Feb 22:54
· 5 commits to master since this release
238e914

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.Builder class for constructing Message objects with a chainable API.
    • Enforces build-time validation for required fields: from, to, subject, and content.
    • Example: Message.builder().subject("Test").from(sender).addTo(recipient).addContent(content).build().
  • 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.
  • Inline Attachments with Content-IDs:

    • Supports inline attachments via dispositionInline() with manual or auto-generated content IDs.
    • Example: <img src="cid:logo"> with Attachment.builder().fromFile("logo.png").dispositionInline("logo").build().
  • 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, and Reply-To recipients (e.g., .addTo(), .addCc(), .addReplyTo()).
  • Concurrency Support:

    • Thread-safe Client for concurrent email sending using thread pools.
  • OAuth Authentication:

    • Integrated with OAuthHttpClient for secure API access using client credentials.

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, and MessageHeaders.

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