📧Sending an Email

Learn how to use the Mailzeet API to send mails to recipients.

This section guides you through the process of sending an email using the Mailzeet API. The Mailzeet API allows you to send transactional emails reliably and efficiently. To get started, you'll need to provide specific details about the email, including sender information, recipient details, subject, template ID, and customizable parameters.

This guide will walk you through the steps to collect these details, format your request, and understand the response.

Step 1: Collect the Email Details

To send an email, you need to gather the following required information:

  • Sender: Information about the sender of the email.

  • Recipients: A list of recipients to whom the email will be sent.

  • Subject: The subject line of the email.

  • Template ID: The ID of the email template to use, if applicable. You can find the templates on the Mailzeet dashboard, on the Templates page.

  • Params: Customizable variables used in the email template.

Fields used for the requests

Below is a detailed table of the fields you need to or can include in your request:

Field NameTypeRequiredDescription

sender

object

no

Details about the sender. Not required if template_id is present and template has default sender set.

sender.email

string

no

Must be an authorized email address for your SMTP server provided on Mailzeet.

sender.name

string

no

Name of the sender.

recipients

object[]

yes

A list of recipient details. Minimum 1, maximum 50.

recipients.email

string

yes

Email address of the recipient.

recipients.name

string

no

Name of the recipient. May not contain ; or ,.

cc

object[]

no

List of CC recipients. Maximum 10.

cc.email

string

yes

Email address of the CC recipient.

cc.name

string

no

Name of the CC recipient. May not contain ; or ,.

bcc

object[]

no

List of BCC recipients. Maximum 10.

bcc.email

string

yes

Email address of the BCC recipient.

bcc.name

string

no

Name of the BCC recipient.

reply_to.email

string

no

Reply-to email address.

reply_to.name

string

no

Name for the reply-to email address.

subject

string

yes *

Subject of the email. Max 255 characters. Not required if template_id is present and template has default subject set.

text

string

yes *

Email represented in a text (text/plain) format. Max size of 1 MB. * Only required if there's no html or template_id present.

html

string

yes *

Email represented in HTML (text/html) format. Max size of 2 MB. * Only required if there's no text or template_id present.

template_id

string

yes *

Template ID to use for the email. * Only required if there's no text or html present.

params

object

no

Allows using personalization in {{var}} syntax. Can be used in the subject, html, text fields, and templates.

Step 2: Send the Request

Once you have collected the necessary details, you can send an email using the Mailzeet API by making a POST request to the following endpoint: POST https://api.mailzeet.com/v1/mails

Example Request Body

{
    "sender": {
        "email": "hello@mailzeet.com",
        "name": "Mailzeet"
    },
    "recipients": [
        {
            "email": "john@mailzeet.com",
            "name": "John Doe"
        }
    ],
    "subject": "Hello from {company}!",
    "text": "This is just a friendly hello from your friends at {company}.",
    "html": "<b>This is just a friendly hello from your friends at {company}.</b>",
    "template_id": "xxxxxx",
    "params": {
        "company": "Mailzeet"
    }
}

Example Response

After sending the request, you will receive a response from the Mailzeet API. The response will confirm whether the email was sent successfully or if there were any errors.

{
    "message": "Email sent successfully.",
    "data": {
        "id": "email-id-12345",
        "status": "sent"
    },
    "errors": null
}

This response includes a message indicating the success of the operation, a data object with the email ID and status, and an errors field which will be null if there are no errors.

By following these steps, you can successfully send emails using the Mailzeet API. If you encounter any issues, refer to the response for error details and adjust your request accordingly.

Here are some examples of the same request in some popular languages.

curl -X POST https://api.mailzeet.com/v1/mails \
-H "Content-Type: application/json" \
-d '{
    "sender": {
        "email": "hello@mailzeet.com",
        "name": "Mailzeet"
    },
    "recipients": [
        {
            "email": "john@mailzeet.com",
            "name": "John Doe"
        }
    ],
    "subject": "Hello from {company}!",
    "text": "This is just a friendly hello from your friends at {company}.",
    "html": "<b>This is just a friendly hello from your friends at {company}.</b>",
    "template_id": "xxxxxx",
    "params": {
        "company": "Mailzeet"
    }
}'

Last updated