Sending Email with Python
Official Python client for scripts and workers.
Read guideInstall the official @mailsurge/node package and send transactional email from Node.js 18+.
Add @mailsurge/node to your project. Node.js 18+ is required.
1
npm install @mailsurge/node
Set MAILSURGE_API_KEY in your environment. A successful send resolves without a response body — the message was accepted and queued for delivery.
1
import Mailsurge from '@mailsurge/node';
2
import { MailsurgeRateLimitError } from '@mailsurge/node';
3
4
const mailsurge = new Mailsurge();
5
6
try {
7
await mailsurge.messages.send({
8
from: 'Acme <no-reply@yourdomain.com>',
9
to: ['customer@example.com'],
10
subject: 'Password reset',
11
html: '<p>Reset your password using the secure link.</p>',
12
text: 'Reset your password using the secure link.',
13
});
14
} catch (error) {
15
if (error instanceof MailsurgeRateLimitError) {
16
console.error('Sending limit reached:', error.body.limit);
17
}
18
19
throw error;
20
}
Move sends off the request cycle and plan for failures before you ship.
Related guides to help you ship production-ready transactional email.
Official Python client for scripts and workers.
Read guideNet::HTTP example for Rails and standalone Ruby.
Read guideVerify a domain, create an API key, and call POST /api/v1/message from your stack.