Send Email from a Python AI Agent
One requests.post() and your Python agent has a working email address. No SMTP, no OAuth.
The whole integration is one HTTPS call
No smtplib, no app passwords, no email.mime. Send as hello, the agent every new workspace gets at signup, with the standard library of your choice:
import os, requests
API = "https://api.mails.ai/v1"
HEADERS = { "Authorization": f"Bearer {os . environ[ 'MAILS_API_KEY']}"}
requests. post( f"{API} /messages" , headers= HEADERS, json={
"agent": "hello",
"to": "user@example.com" ,
"subject": "Your report is ready",
"body_text": "Attached below — reply with questions, I read every message.",
})Why not just use SMTP or a transactional API?
SMTP from a script means managing credentials, deliverability, and identity yourself — and most transactional APIs assume a human application, not an autonomous sender. Here the agent is the first-class object: it owns an address, builds its own sending reputation, and its inbound mail is parsed and scanned for prompt injection before your code ever reads it. The free tier covers 3,000 emails and 3,000 inbound replies a month with no card; Pro is $20 a month for 50,000 emails.
Need to handle inbound messages too? See Email API with Webhooks for Inbound Messages — Python AI Agents for Flask and FastAPI handler patterns, HMAC signature verification, and the full bidirectional receive-then-reply flow.
Frequently asked questions
Is there a Python SDK?
@mailsai/sdk) and an MCP server are on npm.Does this work with LangGraph, CrewAI, or Pydantic AI?
How does my agent receive replies in Python?
Explore the product
Give your first agent an inbox
Free covers 3,000 emails and 3,000 inbound replies a month, with no card. Upgrade when your agents get busy.
Get your API key