AcyMailing
Our siteForumBlog
Sending service
Sending service
  • Quick Start
  • SDKs installation
  • License information
  • Domains
    • Register new domain
    • Update domain
    • Delete domain
  • Send email
Powered by GitBook
On this page

Send email

Send a email with our API

curl https://api.acymailer.com/api/send \
 -X POST \
 -H 'Content-Type: application/json' \
 -H 'API-KEY: your-license-key' \
 -H 'Version: external' \
 -d '{"email":"Date: Thu, 7 Mar 2024 12:15:03 +0100\r\nFrom: Email example <email@example.com>\r\nCc: cc@recipients.com\r\nReply-To: Email no-reply <no-reply@example.com>\r\nMessage-ID: <fFkkPmogsPGI9joSa6txvJno0DBX20VhMQgu6Hk6Q@rleclercq-A027-I00000>\r\nX-Mailer: PHPMailer 6.9.1 (https:\/\/github.com\/PHPMailer\/PHPMailer)\r\nMIME-Version: 1.0\r\nContent-Type: multipart\/alternative;\r\n boundary=\"b1=_fFkkPmogsPGI9joSa6txvJno0DBX20VhMQgu6Hk6Q\"\r\nContent-Transfer-Encoding: 8bit\r\nTo: email@recipients.com\r\nSubject: This is the subject\r\n\r\n--b1=_fFkkPmogsPGI9joSa6txvJno0DBX20VhMQgu6Hk6Q\r\nContent-Type: text\/plain; charset=us-ascii\r\n\r\nThis is the alternative body. Only text here\r\n\r\n--b1=_fFkkPmogsPGI9joSa6txvJno0DBX20VhMQgu6Hk6Q\r\nContent-Type: text\/html; charset=us-ascii\r\n\r\nThis is the body with a <h1>title<\/h1> and a <a href=\"https:\/\/www.acymailing.com\">link<\/a>.\r\n\r\n\r\n--b1=_fFkkPmogsPGI9joSa6txvJno0DBX20VhMQgu6Hk6Q--\r\n","domainsUsed":["example.com"]}'
<?php
  
$acymailer = new AcyMailer\SendingService('your-license-key');

$optionsSendEmail = [
    'to' => 'email@recipients.com',
    'subject' => 'This is the subject',
    'body' => 'This is the body with a <h1>title</h1> and a <a href="https://www.acymailing.com">link</a>.',
    'alt_body' => 'This is the alternative body. Only text here', // optionnal
    'from_email' => 'email@example.com',
    'from_name' => 'Email example',
    'reply_to_email' => 'no-reply@example.com', // optional, default to from_email
    'reply_to_name' => 'Email no-reply', // optional, default to from_name
    'bounce_email' => 'bounce@example.com', // optional, default to from_email
    'cc' => ['cc@recipients.com'], // optional, must be an array
    'attachments' => ['/path/to/attachment.png'], // optional, must be an array
];

$response = $acymailer->send($optionsSendEmail);
import {AcyMailer} from '@acymailing/sending-service';

const mailer = new AcyMailer('your-license-key');

const email = {
    to: 'email@recipients.com',
    subject: 'test email from node lib',
    body: '<h1>Hello</h1>, this is a test email from the node lib', // altBody?: string,
    fromEmail: 'email@example.com',
    fromName: 'Email example',
    replyToEmail: 'no-reply@example.com',
    replyToName: 'Email no-reply',
    bounceEmail: 'bounce@example.com', // cc?: string[];
    attachments: [
        '/paht/to/attachment.png'
    ]
};

const response = await mailer.sendEmail(email);

POST /api/send

Send an email with the API

Headers

Name
Value

Content-Type

application/json

API-KEY

<license-key>

Version

Must be "external"

Body

{
    "email":"Date: Thu, 7 Mar 2024 12:15:03 +0100\r\nFrom: Email example <email@example.com>\r\nCc: cc@recipients.com\r\nReply-To: Email no-reply <no-reply@example.com>\r\nMessage-ID: <fFkkPmogsPGI9joSa6txvJno0DBX20VhMQgu6Hk6Q@rleclercq-A027-I00000>\r\nX-Mailer: PHPMailer 6.9.1 (https:\/\/github.com\/PHPMailer\/PHPMailer)\r\nMIME-Version: 1.0\r\nContent-Type: multipart\/alternative;\r\n boundary=\"b1=_fFkkPmogsPGI9joSa6txvJno0DBX20VhMQgu6Hk6Q\"\r\nContent-Transfer-Encoding: 8bit\r\nTo: email@recipients.com\r\nSubject: This is the subject\r\n\r\n--b1=_fFkkPmogsPGI9joSa6txvJno0DBX20VhMQgu6Hk6Q\r\nContent-Type: text\/plain; charset=us-ascii\r\n\r\nThis is the alternative body. Only text here\r\n\r\n--b1=_fFkkPmogsPGI9joSa6txvJno0DBX20VhMQgu6Hk6Q\r\nContent-Type: text\/html; charset=us-ascii\r\n\r\nThis is the body with a <h1>title<\/h1> and a <a href=\"https:\/\/www.acymailing.com\">link<\/a>.\r\n\r\n\r\n--b1=_fFkkPmogsPGI9joSa6txvJno0DBX20VhMQgu6Hk6Q--\r\n",
    "domainsUsed":["example.com"],
    "isTransactional": false
}
  • email must be your email in a MIME format

  • domainUsed must be an array of all domains used in the email for the the 3 email addresses: - From email - Bounce email - Reply-to email

  • isTransactional must be either true or false

For example:

Same domain but different email addresses: - From: marketing@your-domain.com - Reply-to: no-reply@your-domain.com - Bounce: bounce@your-domain.com The value should be ["your-domain.com"]

Different domain and different email addresses: - From: marketing@your-domain.com - Reply-to: no-reply@your-domain.com - Bounce: bounce@your-other-domain.com The value should be ["example.com", "your-other-domain.com"]

Response

{
    "code": 22,
    "message": "Email sent!"
}
// Unknown error 
{
    "code": 2,
    "message": "An error occurred, see details in the sending service logs file in the configuration",
    "logs": "<details>"
}

// No email in the body of the request
{
    "code": 16,
    "message": "The email is missing"
}

// Unknown error
{
    "code": "<details>",
    "message": "An error occurred, please see details in the browser console",
    "logs": "<details>"
}
// Domain not found
{
    "code": 20,
    "message": "Domain not found: %s",
    "messageData": "[\"<domain-missing>\"]"
}

// The domain exist but is not attached for this license
{
    "code": 20,
    "message": "No domain found for this licence"
}
// License under verification
{
    "code": 15,
    "message": "Your license is under verification because we detected an unsafe content in your previously sent email"
}

// License blocked
{
    "code": 15,
    "message": "Your license is blocked"
}

// No credits left on your license
{
    "code": 18,
    "message": "No credits left"
}

// Error when handling credits when sending email
{
    "code": 7,
    "message": "An error related to the remaining credits occurred when trying to send an email"
}
PreviousDelete domain

Last updated 12 months ago