Base URL: https://api.zeptomail.com/v1.1
---
1. Send Basic Email
Write to /tmp/zeptomail_request.json:
```json
{
"from": {
"address": "noreply@yourdomain.com",
"name": "Your App"
},
"to": [
{
"email_address": {
"address": "user@example.com",
"name": "User"
}
}
],
"subject": "Welcome to Our Service",
"htmlbody": "Welcome!
Thank you for signing up.
"
}
```
Then run:
```bash
bash -c 'curl -s "https://api.zeptomail.com/v1.1/email" -X POST --header "Authorization: Zoho-enczapikey ${ZEPTOMAIL_API_KEY}" --header "Content-Type: application/json" -d @/tmp/zeptomail_request.json'
```
---
2. Send Plain Text Email
Write to /tmp/zeptomail_request.json:
```json
{
"from": {
"address": "noreply@yourdomain.com",
"name": "Your App"
},
"to": [
{
"email_address": {
"address": "user@example.com",
"name": "User"
}
}
],
"subject": "Your OTP Code",
"textbody": "Your one-time password is: 123456\n\nThis code expires in 10 minutes."
}
```
Then run:
```bash
bash -c 'curl -s "https://api.zeptomail.com/v1.1/email" -X POST --header "Authorization: Zoho-enczapikey ${ZEPTOMAIL_API_KEY}" --header "Content-Type: application/json" -d @/tmp/zeptomail_request.json'
```
---
3. Send Email with Tracking
Enable open and click tracking:
Write to /tmp/zeptomail_request.json:
```json
{
"from": {
"address": "noreply@yourdomain.com",
"name": "Your App"
},
"to": [
{
"email_address": {
"address": "user@example.com",
"name": "User"
}
}
],
"subject": "Order Confirmation #12345",
"htmlbody": "Your order has been confirmed. Track your order
",
"track_clicks": true,
"track_opens": true,
"client_reference": "order-12345"
}
```
Then run:
```bash
bash -c 'curl -s "https://api.zeptomail.com/v1.1/email" -X POST --header "Authorization: Zoho-enczapikey ${ZEPTOMAIL_API_KEY}" --header "Content-Type: application/json" -d @/tmp/zeptomail_request.json'
```
---
4. Send to Multiple Recipients (CC/BCC)
Write to /tmp/zeptomail_request.json:
```json
{
"from": {
"address": "noreply@yourdomain.com",
"name": "Your App"
},
"to": [
{
"email_address": {
"address": "user1@example.com",
"name": "User 1"
}
}
],
"cc": [
{
"email_address": {
"address": "user2@example.com",
"name": "User 2"
}
}
],
"bcc": [
{
"email_address": {
"address": "admin@example.com",
"name": "Admin"
}
}
],
"subject": "Team Update",
"htmlbody": "Here is the latest update for the team.
",
"reply_to": [
{
"address": "support@yourdomain.com",
"name": "Support"
}
]
}
```
Then run:
```bash
bash -c 'curl -s "https://api.zeptomail.com/v1.1/email" -X POST --header "Authorization: Zoho-enczapikey ${ZEPTOMAIL_API_KEY}" --header "Content-Type: application/json" -d @/tmp/zeptomail_request.json'
```
---
5. Send Email with Attachment (Base64)
```bash
# Encode file to base64
FILE_CONTENT=$(base64 -i /path/to/file.pdf)
```
Write to /tmp/zeptomail_request.json:
```json
{
"from": {
"address": "noreply@yourdomain.com",
"name": "Your App"
},
"to": [
{
"email_address": {
"address": "user@example.com",
"name": "User"
}
}
],
"subject": "Your Invoice",
"htmlbody": "Please find your invoice attached.
",
"attachments": [
{
"name": "invoice.pdf",
"mime_type": "application/pdf",
"content": "${FILE_CONTENT}"
}
]
}
```
Then run:
```bash
bash -c 'curl -s "https://api.zeptomail.com/v1.1/email" -X POST --header "Authorization: Zoho-enczapikey ${ZEPTOMAIL_API_KEY}" --header "Content-Type: application/json" -d @/tmp/zeptomail_request.json'
```
---
6. Send Email with Inline Image
```bash
# Encode image to base64
IMAGE_CONTENT=$(base64 -i /path/to/logo.png)
```
Write to /tmp/zeptomail_request.json:
```json
{
"from": {
"address": "noreply@yourdomain.com",
"name": "Your App"
},
"to": [
{
"email_address": {
"address": "user@example.com",
"name": "User"
}
}
],
"subject": "Newsletter",
"htmlbody": "
Welcome to our newsletter!
",
"inline_images": [
{
"cid": "logo",
"name": "logo.png",
"mime_type": "image/png",
"content": "${IMAGE_CONTENT}"
}
]
}
```
Then run:
```bash
bash -c 'curl -s "https://api.zeptomail.com/v1.1/email" -X POST --header "Authorization: Zoho-enczapikey ${ZEPTOMAIL_API_KEY}" --header "Content-Type: application/json" -d @/tmp/zeptomail_request.json'
```
---
7. Send Templated Email
Use pre-defined templates with merge fields:
Write to /tmp/zeptomail_request.json:
```json
{
"template_key": "your-template-key",
"from": {
"address": "noreply@yourdomain.com",
"name": "Your App"
},
"to": [
{
"email_address": {
"address": "user@example.com",
"name": "User"
}
}
],
"merge_info": {
"user_name": "John",
"order_id": "12345",
"total": "$99.00"
}
}
```
Then run:
```bash
bash -c 'curl -s "https://api.zeptomail.com/v1.1/email/template" -X POST --header "Authorization: Zoho-enczapikey ${ZEPTOMAIL_API_KEY}" --header "Content-Type: application/json" -d @/tmp/zeptomail_request.json'
```
Template example (in ZeptoMail dashboard):
```html
Hi {{user_name}},
Your order #{{order_id}} totaling {{total}} has been shipped!
```
---
8. Batch Send (Multiple Recipients)
Send to up to 500 recipients with personalized merge fields:
Write to /tmp/zeptomail_request.json:
```json
{
"from": {
"address": "noreply@yourdomain.com",
"name": "Your App"
},
"subject": "Your Monthly Report - {{month}}",
"htmlbody": "Hi {{name}},
Here is your report for {{month}}.
",
"to": [
{
"email_address": {
"address": "user1@example.com",
"name": "User 1"
},
"merge_info": {
"name": "Alice",
"month": "December"
}
},
{
"email_address": {
"address": "user2@example.com",
"name": "User 2"
},
"merge_info": {
"name": "Bob",
"month": "December"
}
}
]
}
```
Then run:
```bash
bash -c 'curl -s "https://api.zeptomail.com/v1.1/email/batch" -X POST --header "Authorization: Zoho-enczapikey ${ZEPTOMAIL_API_KEY}" --header "Content-Type: application/json" -d @/tmp/zeptomail_request.json'
```
---
9. Batch Send with Template
Write to /tmp/zeptomail_request.json:
```json
{
"template_key": "your-template-key",
"from": {
"address": "noreply@yourdomain.com",
"name": "Your App"
},
"to": [
{
"email_address": {
"address": "user1@example.com",
"name": "User 1"
},
"merge_info": {
"user_name": "Alice",
"code": "ABC123"
}
},
{
"email_address": {
"address": "user2@example.com",
"name": "User 2"
},
"merge_info": {
"user_name": "Bob",
"code": "XYZ789"
}
}
]
}
```
Then run:
```bash
bash -c 'curl -s "https://api.zeptomail.com/v1.1/email/template/batch" -X POST --header "Authorization: Zoho-enczapikey ${ZEPTOMAIL_API_KEY}" --header "Content-Type: application/json" -d @/tmp/zeptomail_request.json'
```
---