Skip to main content
Send an email in a few minutes. This guide walks through sending your first request to the MailChannels Email API. The Python SDK is open source. Browse the source code.

Prerequisites

Before your first request, complete the following steps.
1

Create a MailChannels account

Sign up if you don’t already have an account.
2

Generate an API key

Open Account > API Keys and click Create API Key. Add a descriptive label and set the scope to api. Copy the key; you won’t be able to see it again.
Treat your API key like a password. Don’t commit it to source control or expose it in client-side code.
3

Add a Domain Lockdown DNS record

For each domain you’ll send from, add a TXT record on the _mailchannels subdomain authorizing your account to send. Replace examplecorp with your MailChannels account ID (visible in the panel footer when you log in):
See the Domain Lockdown guide for details.
4

Update your SPF DNS record

Add MailChannels to the SPF record on each sending domain so recipient servers accept your mail:
If you already have an SPF record, merge in include:relay.mailchannels.net rather than creating a second record. A domain must have only one SPF record.
Your sending domain must resolve. It needs a valid A or MX record. Without one, mail from the domain is rejected with 550 5.1.2 [SDNF] Sender Domain Not Found. Most registered domains already have these records. Confirm yours with the check-domain tool. See Troubleshooting for details.

Install the Python SDK

Python

Send your first email

To send an email, provide the recipients, sender, subject, and message content. The example below sends an HTML email to a single recipient.
Until you add a payment method, sending is restricted to addresses belonging to verified Users on your account. Add a user, click the link in the verification email, then use that address as the to email below.
Set the following before running:
  • MAILCHANNELS_API_KEY — the API key generated above.
  • FROM_EMAIL — an address on the domain you configured with Domain Lockdown and SPF above (e.g. hello@example.com if you used example.com in the Domain Lockdown and SPF DNS records).
  • TO_EMAIL — a recipient inbox you can check, e.g. the address you use to sign up for MailChannels.

Next steps

  • Read the webhooks guide to learn how to get real-time notifications about email delivery, bounces, and complaints.
  • Explore the API reference to see what else you can do with the API.