Attachments
Send emails with file attachments.
Overview
Attach files to your emails by including them as base64-encoded content. SENTD supports common file types including PDFs, images, and documents.
Sending attachments
Include attachments in your send request:
{
"from": "invoices@yourdomain.com",
"to": "customer@example.com",
"subject": "Your Invoice #12345",
"html": "<p>Please find your invoice attached.</p>",
"attachments": [
{
"filename": "invoice-12345.pdf",
"content": "JVBERi0xLjQKJe...", // base64 encoded
"type": "application/pdf"
}
]
}Node.js example
import fs from 'fs';
import { SENTD } from '@sentd/node';
const sentd = new SENTD('your_api_key');
// Read file and convert to base64
const pdfBuffer = fs.readFileSync('./invoice.pdf');
const pdfBase64 = pdfBuffer.toString('base64');
const result = await sentd.emails.send({
from: 'invoices@yourdomain.com',
to: 'customer@example.com',
subject: 'Your Invoice',
html: '<p>Please find your invoice attached.</p>',
attachments: [
{
filename: 'invoice.pdf',
content: pdfBase64,
type: 'application/pdf'
}
]
});Multiple attachments
Attach multiple files by adding them to the array:
{
"from": "reports@yourdomain.com",
"to": "team@example.com",
"subject": "Monthly Reports",
"html": "<p>Attached are this month's reports.</p>",
"attachments": [
{
"filename": "sales-report.pdf",
"content": "JVBERi0xLjQK...",
"type": "application/pdf"
},
{
"filename": "analytics.xlsx",
"content": "UEsDBBQAAAAI...",
"type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
},
{
"filename": "summary.png",
"content": "iVBORw0KGgo...",
"type": "image/png"
}
]
}Supported file types
| Type | MIME Type |
|---|---|
| application/pdf | |
| PNG | image/png |
| JPEG | image/jpeg |
| GIF | image/gif |
| Word | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
| Excel | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
| CSV | text/csv |
| Text | text/plain |
Limits
Size limits:
- Maximum attachment size: 10MB per file
- Maximum total attachments: 25MB per email
- Maximum attachments: 10 files per email