Mail API Documentation

This API allows you to send emails using PHPMailer. You can configure all PHPMailer public properties and methods (except send) via JSON. The API will enqueue the email for asynchronous processing.

Endpoint: /sendmail

The /sendmail endpoint accepts a JSON body with the following structure:

Request Structure

{ "emails":[ { "isSMTP": null, "Host": "smtp.example.com", "SMTPAuth": true, "Username": "user@example.com", "Password": "yourpassword", "SMTPSecure": "tls", "Port": 587, "setFrom": { "address": "user@example.com", "name": "Sender Name" }, "addAddress": { "address": "recipient@example.com", "name": "Recipient Name" }, "Subject": "Test Email", "Body": "This is a test email.", "isHTML": true, "addStringAttachment": { "string": "file contents", "filename": "file.txt", encoding: "base64"(default), type: "text/plain"(default reads filename and guesses mime), disposition: "attachment"(default) }, "callBackUrl": "callback url", } } ] }

Parameters

Supported Methods and Properties

The following PHPMailer methods and properties are supported. For a full list, see the PHPMailer documentation.

Name Type Named Parameters / Value Description
isSMTP method null Enable SMTP mode
Host property string SMTP server hostname
SMTPAuth property bool Enable SMTP authentication
Username property string SMTP username
Password property string SMTP password
SMTPSecure property string ("tls" or "ssl") Encryption system to use
Port property int SMTP port
setFrom method { "address": string, "name": string (optional) } Set sender address and name
addAddress method { "address": string, "name": string (optional) } Add recipient address and name
addCC method { "address": string, "name": string (optional) } Add CC address and name
addBCC method { "address": string, "name": string (optional) } Add BCC address and name
addReplyTo method { "address": string, "name": string (optional) } Add reply-to address and name
Subject property string Email subject
Body property string Email body (HTML or plain text)
AltBody property string Alternative plain-text body
isHTML property bool Set to true to send HTML email
addAttachment (DO NOT USE IT, use addStringAttachment if attachment is needed) method { "path": string, "name": string (optional) } Add attachment (path, optional name)
addStringAttachment method { "string": "file contents", "filename": "file.txt", encoding: "base64"(default), type: "text/plain"(default reads filename and guesses mime), disposition: "attachment"(default) } Add attachment (path, optional name)
Priority property int Email priority (1 = High, 3 = Normal, 5 = Low)
CharSet property string Character set (e.g. "UTF-8")
WordWrap property int Word wrap length
addCustomHeader method { "name": string, "value": string } Add a custom header

Example Request

{ "emails":[ { "isSMTP": null, "Host": "smtp.example.com", "SMTPAuth": true, "Username": "user@example.com", "Password": "yourpassword", "SMTPSecure": "tls", "Port": 587, "setFrom": { "address": "user@example.com", "name": "Sender Name" }, "addAddress": { "address": "recipient@example.com", "name": "Recipient Name" }, "Subject": "Test Email", "Body": "This is a test email.", "isHTML": true, "addAttachment": { "path": "/tmp/file.txt", "name": "file.txt" } "addStringAttachment": { "string": "file contents", "filename": "file.txt", encoding: "base64"(default), type: "text/plain"(default reads filename and guesses mime), disposition: "attachment"(default) }, "callBackUrl": "callback url", } ] }

Example Response

{ "success": true, "data": [ { "messageId": asd-123-adfasd, "status": "success | error", "email": "example@mailexample.xmp" } ], "message": "", "statusCode": 200 }

Example Callback response

{ "messageId": asd-123-adfasd, "status": "success | error", "message": "(filled only if error)", }
Note: