Sending Email with Node.js
Official Node.js client with typed errors.
Read guideInstall the official mailsurge package and send transactional email from Python 3.10+.
Add the mailsurge package to your environment. Python 3.10+ is required.
1
pip install mailsurge
Set MAILSURGE_API_KEY in your environment. Use from_ because from is reserved in Python.
1
from mailsurge import Mailsurge, MailsurgeRateLimitError
2
3
with Mailsurge() as client:
4
try:
5
client.messages.send(
6
from_='Acme <no-reply@yourdomain.com>',
7
to=['customer@example.com'],
8
subject='Password reset',
9
html='<p>Reset your password using the secure link.</p>',
10
text='Reset your password using the secure link.',
11
)
12
except MailsurgeRateLimitError as error:
13
print('Sending limit reached:', error.body.get('limit'))
14
raise
Keep sends off the web request path and handle API failures explicitly.
Related guides to help you ship production-ready transactional email.
Official Node.js client with typed errors.
Read guideFramework-agnostic cURL example for any PHP app.
Read guideVerify a domain, create an API key, and call POST /api/v1/message from your stack.