Getting started
In this guide, you'll set up your account and send your first email using the Twilio Email API.
Before you begin, ensure you have the following:
- A Twilio account: Sign up for a free account.
- A Verified Sender: An approved domain identity in the Twilio Console that matches the domain of the
fromaddress. - Compliance: Ensure your email content and recipient lists comply with regional anti-spam regulations, for example CAN-SPAM and GDPR.
The API uses HTTP Basic authentication. To authenticate, include a Basic Auth header using one of the following pairs:
- Your Account SID and Auth Token
- Your API Key SID and API Key Secret
1curl -X POST 'https://comms.twilio.com/v1/Emails' \2-H 'Content-Type: application/json' \3-d '{4"from": {5"address": "support@example.com",6"name": "Support Team"7},8"to": [9{10"address": "john.doe@example.com",11"name": "John Doe"12}13],14"content": {15"subject": "Your subject line",16"html": "<p>Your message content in HTML format.</p>",17"text": "Your message content in plain text."18}19}' \20-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
Response (202 Accepted):
1{2"operationId": "comms_operation_01h9krwprkeee8fzqspvwy6nq8",3"operationLocation": "https://comms.twilio.com/v1/Emails/Operations/comms_operation_01h9krwprkeee8fzqspvwy6nq8"4}
See Mail Send for more details on sending emails, including how to send to multiple recipients and use advanced features like templates and attachments.