Libraries and SDKs
Official Maileroo SDKs and libraries for PHP, Laravel, Node.js, Python, .NET, Go, and Java to help you integrate quickly.
We offer SDK and libraries for various programming languages to help you integrate Maileroo's APIs quickly and easily. These libraries handle authentication, request formatting, and error handling, allowing you to focus on building your application.
PHP
To read more about the PHP SDK, please visit the GitHub repository.
PHP Installation
composer require maileroo/maileroo-php-sdkPHP Quick Start
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Maileroo\MailerooClient;
use Maileroo\EmailAddress;
use Maileroo\Attachment;
// Initialize the client
$client = new MailerooClient('your-api-key');
// Send a basic email
$reference_id = $client->sendBasicEmail([
'from' => new EmailAddress('[email protected]', 'Sender Name'),
'to' => [new EmailAddress('[email protected]', 'Recipient Name')],
'subject' => 'Hello from Maileroo!',
'html' => '<h1>Hello World!</h1><p>This is a test email.</p>',
'plain' => 'Hello World! This is a test email.'
]);
echo "Email sent with reference ID: " . $reference_id;Laravel
To learn more about the Laravel Transport, please visit the GitHub repository.
Laravel Installation
composer require maileroo/maileroo-laravel-transportLaravel Configuration
Update your .env file with your Maileroo API key and set the mailer to use Maileroo.
MAIL_MAILER=maileroo
MAILEROO_API_KEY=[YOUR_MAILEROO_API_KEY]
MAIL_FROM_ADDRESS="[YOUR_MAILEROO_FROM_ADDRESS]"
MAIL_FROM_NAME="[YOUR_MAILEROO_FROM_NAME]"Laravel Usage
After configuring the transport, you can use Laravel's built-in mail functionality to send emails via Maileroo. There are no additional changes needed in your code.
Node.js
To learn more about the Node.js SDK, please visit the npm package page.
Node.js Installation
npm install maileroo-sdkNode.js Quick Start
import {MailerooClient, EmailAddress, Attachment} from "maileroo-sdk";
const client = new MailerooClient("your-api-key");
const referenceId = await client.sendBasicEmail({
from: new EmailAddress("[email protected]", "Sender Name"),
to: [new EmailAddress("[email protected]", "Recipient Name")],
subject: "Hello from Maileroo!",
html: "<h1>Hello World!</h1><p>This is a test email.</p>",
plain: "Hello World! This is a test email."
});
console.log("Email sent with reference ID:", referenceId);Python
To learn more about the Python SDK, please visit the PyPI package page.
Python Installation
pip install mailerooPython Quick Start
from maileroo import MailerooClient, EmailAddress
# Initialize the client
client = MailerooClient("your-api-key")
# Send a basic email
reference_id = client.send_basic_email({
"from": EmailAddress("[email protected]", "Sender Name"),
"to": [EmailAddress("[email protected]", "Recipient Name")],
"subject": "Hello from Maileroo!",
"html": "<h1>Hello World!</h1><p>This is a test email.</p>",
"plain": "Hello World! This is a test email."
})
print("Email sent with reference ID:", reference_id).NET
To learn more about the .NET SDK, please visit the NuGet package page.
.NET Installation
dotnet add package Maileroo.DotNet.SDK.NET Quick Start
var apiKey = "YOUR_API_KEY";
var client = new MailerooClient(apiKey);
var from = new EmailAddress("[email protected]", "Your Company");
var to = new EmailAddress("[email protected]", "John Doe");
try
{
var payload = new Dictionary<string, object?>
{
["from"] = from,
["to"] = new List<EmailAddress> { to },
["subject"] = "Hello from Maileroo .NET 6",
["html"] = "<h1>Hello World</h1><p>This came from the C# SDK test.</p>",
["plain"] = "Hello World (plain text fallback)",
};
var refId = await client.SendBasicEmailAsync(payload);
Console.WriteLine($"Email queued! Reference ID: {refId}");
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}Go
To learn more about the Golang SDK, please visit the GitHub repository.
Go Installation
go get github.com/maileroo/maileroo-go-sdkGo Quick Start
client, err := maileroo.NewClient("your-api-key", 30)
if err != nil {
log.Fatalf("Failed to create client: %v", err)
}
htmlContent := "<h1>Test Email</h1><p>This is a test email from the Maileroo Go SDK.</p>"
plainContent := "Test Email\n\nThis is a test email from the Maileroo Go SDK."
referenceId, err := client.SendBasicEmail(context.Background(), maileroo.BasicEmailData{
From: maileroo.NewEmail("YOUR_EMAIL_ADDRESS", "Your Name"),
To: []maileroo.EmailAddress{
maileroo.NewEmail("RECIPIENT_EMAIL_ADDRESS", "Recipient Name"),
},
Cc: []maileroo.EmailAddress{
maileroo.NewEmail("CC_EMAIL_ADDRESS", "CC Name"),
},
Subject: "Test Email from Maileroo Go SDK",
HTML: &htmlContent,
Plain: &plainContent,
})
if err != nil {
log.Fatalf("Failed to send email: %v", err)
}
log.Printf("Email sent with reference ID: %s", referenceId)Java
To learn more about the Java SDK, please visit the GitHub repository or Maven Central.
Java Installation
Add the following dependency to your pom.xml file:
<dependency>
<groupId>com.maileroo</groupId>
<artifactId>maileroo-java-sdk</artifactId>
<version>1.0.0</version>
</dependency>Java Quick Start
import com.maileroo.*;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) throws Exception {
MailerooClient client = new MailerooClient("your-api-key", Duration.ofSeconds(30));
Map<String,Object> email = new HashMap<>();
email.put("from", new EmailAddress("[email protected]", "Sender"));
email.put("to", new EmailAddress("[email protected]", "Recipient"));
email.put("subject", "Hello from Maileroo!");
email.put("html", "<h1>Hello World!</h1><p>This is a test email.</p>");
email.put("plain", "Hello World! This is a test email.");
String refId = client.sendBasicEmail(email);
System.out.println("Email sent with reference ID: " + refId);
}
}Community Contributions
If you are interested in contributing SDKs or libraries at Maileroo, please create your GitHub repository and let us know. We will be happy to link to your repository from our documentation.