Sending Emails
Now that you've set up your API key and Domain Lockdown record(s), it's time to send your first email!
To send email, we'll be making a POST
request to the /send
endpoint. In each POST
request,
- The hostname is
https://api.mailchannels.net/tx/v1/send
- Your API key is sent via the
X-Api-Key
header; - The
Content-Type
is set toapplication/json
; and, - A JSON data structure sent as the
POST
data payload encodes the envelope and content of the email message.
Heres's a few curl examples to get you started sending emails with MailChannels Email API in minutes. To make use of these examples you'll need access to a text editor, and a terminal that has curl installed.
curl is typically pre-installed on most operating systems. To verify if curl is available and functioning on your system, follow these steps:
- Open a command prompt or terminal
- Type the following command and press Enter:
curl --version
- If curl is installed, you'll see version information displayed
If you receive an error message or the command is not recognized, it means curl is not installed on your system. In this case, refer to your operating system's official documentation for installation instructions.
For more detailed information or for how to integrate Email API in any of our supported languages you can visit our API Reference Documentation
Example: Send a Plain Text Email
curl -X POST "https://api.mailchannels.net/tx/v1/send" \
-H 'X-Api-Key: YOUR-API-KEY' \
-H 'Content-Type: application/json' \
-d '{
"personalizations": [
{
"to": [
{
"email": "recipient@example.net",
"name": "Sakura Tanaka"
}
],
}
],
"from": {
"email": "sender@example.com",
"name": "Priya Patel"
},
"subject": "Testing Email API",
"content": [
{
"type": "text/plain",
"value": "Hi Sakura. This is just a test from Priya."
}
]
}'