1. Installation
Add the SDK to your project using Maven or Gradle:
< dependency >
< groupId > co.lettermint </ groupId >
< artifactId > lettermint </ artifactId >
< version > LATEST </ version >
</ dependency >
2. Send your first email
Initialize the client with your API token:
import co.lettermint.Lettermint;
Lettermint lettermint = new Lettermint ( "your-api-key" );
Send your first email:
SendEmailResponse response = lettermint . email ()
. from ( "John Doe <[email protected] >" )
. to ( "[email protected] " )
. subject ( "Hello from Lettermint!" )
. text ( "Hello! This is a test email." )
. send ();
System . out . println ( "Email sent with ID: " + response . getMessageId ());
3. Email Features
Basic Email
Send a simple text or HTML email:
lettermint . email ()
. from ( "John Doe <[email protected] >" )
. to ( "[email protected] " )
. subject ( "Your account is ready!" )
. html ( "<h1>Welcome!</h1><p>Thanks for signing up.</p>" )
. text ( "Welcome! Thanks for signing up." )
. send ();
Multiple Recipients
Send to multiple recipients using CC and BCC:
Custom Headers and Reply-To
Add custom headers and set reply-to addresses:
import java.util.Map;
lettermint . email ()
. from ( "[email protected] " )
. to ( "[email protected] " )
. replyTo ( "[email protected] " )
. subject ( "Support Ticket #12345" )
. headers ( Map . of (
"X-Priority" , "1" ,
"X-Ticket-ID" , "12345"
))
. html ( "<p>Your support ticket has been updated.</p>" )
. send ();
Add metadata for tracking and webhook payloads:
import java.util.Map;
lettermint . email ()
. from ( "[email protected] " )
. to ( "[email protected] " )
. subject ( "Order Confirmation" )
. metadata ( Map . of (
"order_id" , "12345" ,
"customer_id" , "cust_789" ,
"campaign" , "order_confirmation"
))
. html ( "<p>Your order has been confirmed.</p>" )
. send ();
Metadata is included in webhook payloads but not added to the actual email headers. Use it for tracking and analytics purposes.
Categorize emails for filtering and analytics:
lettermint . email ()
. from ( "[email protected] " )
. to ( "[email protected] " )
. subject ( "System Alert" )
. tag ( "system-alerts" )
. html ( "<p>Critical system alert detected.</p>" )
. send ();
One tag per message. Tags can contain letters, numbers, hyphens, underscores, and spaces (max 255 characters).
See Tags documentation for more details.
Route Selection
Direct emails to specific routes within your project:
File Attachments
Attach files to your emails:
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Base64;
// Read file content
byte [] fileContent = Files . readAllBytes ( Path . of ( "/path/to/document.pdf" ));
String encodedContent = Base64 . getEncoder (). encodeToString (fileContent);
lettermint . email ()
. from ( "[email protected] " )
. to ( "[email protected] " )
. subject ( "Your Invoice" )
. html ( "<p>Please find your invoice attached.</p>" )
. attach ( "invoice.pdf" , encodedContent)
. send ();
4. Response
SendEmailResponse response = lettermint . email ()
. from ( "John Doe <[email protected] >" )
. to ( "[email protected] " )
. subject ( "Test" )
. text ( "Hello!" )
. send ();
System . out . println ( response . getMessageId ()); // Email ID
System . out . println ( response . getStatus ()); // Current status
Next Steps
GitHub Repository Find the complete source code, report issues, or contribute on GitHub.