Email API for Python

A reliable Python email API for straightforward transactional email delivery.

MailerSend

Easy integration with your Python app

An intuitive Python email API and SDK that you can start sending with in minutes. Fast, async-ready, and built for modern Python applications.
Read our API docs
from mailersend import emails

mailer = emails.NewEmail()

mail_body = {}

mail_from = {
    "name": "Your Name",
    "email": "your@domain.com",
}

recipients = [
    {
        "name": "Your Client",
        "email": "your@client.com",
    }
]

mailer.set_mail_from(mail_from, mail_body)
mailer.set_mail_to(recipients, mail_body)
mailer.set_subject("Hello!", mail_body)
mailer.set_html_content("Greetings from the team, you got this message through MailerSend.", mail_body)
mailer.set_plaintext_content("Greetings from the team, you got this message through MailerSend.", mail_body)

mailer.send(mail_body)
MailerSend

SMTP support when you need it

Fast, secure, reliable SMTP server for developers who prefer to use Python’s built-in smtplib module or Flask-Mail, or need SMTP credentials for use with legacy systems.

MailerSend

Flexible inbound email processing

MailerSend's inbound routes let you receive emails and attachments, forwarding JSON-parsed email content to an API endpoint or email address.

From static to smart with dynamic email templates

Create a single template for each use case and send them to thousands of recipients. Insert variables, product blocks, and dynamic tables at the click of a button for automatic personalization.
Learn more
from mailersend import emails
from dotenv import load_dotenv

load_dotenv()

mailer = emails.NewEmail(os.getenv('MAILERSEND_API_KEY'))

# define an empty dict to populate with mail values
mail_body = {}

mail_from = {
    "name": "Your Name",
    "email": "your@domain.com",
}

recipients = [
    {
        "name": "Your Client",
        "email": "your@client.com",
    }
]


variables = [
    {
        "email": "your@client.com",
        "substitutions": [
            {
                "var": "foo",
                "value": "bar"
            },
        ]
    }
]


mailer.set_mail_from(mail_from, mail_body)
mailer.set_mail_to(recipients, mail_body)
mailer.set_subject("Hello from {$company}", mail_body)
mailer.set_template("templateID", mail_body)
mailer.set_personalization(variables, mail_body)

mailer.send(mail_body)
MailerSend

Better email management with real-time validation API

Immediately verify email addresses upon entry by checking for SMTP responses, valid MX records, disposable domains and more. Flag or block invalid emails and provide real-time user feedback.

Technical support when you need it

Our friendly and knowledgeable customer support team looks at each and every case, always aiming to provide the best solutions in record time. Get help via email or live chat.

93% satisfaction rate
100% response rate
24/7 support hours
I would recommend MailerSend because of the great support I got every time I struggled with something. Fast response times and competent help is my main experience so far. The API documentation and integration are straightforward. Templates can be handled by marketing without developer skills.
Norbert N. CTO
Before MailerSend, we were always worried that emails would go to spam or promotions, but now our clients sometimes ask "How did your FIRST email get into my inbox with a star on it?". For us, email is critical for the businesses that we help and MailerSend plays a critical role. Better still, they have humans that respond and read what you write to them.
Rodrigo S. CEO
Very good tool, it took me just one day to get it working on production. The interface is clean with everything exactly where expected. It works fantastically—emails are delivered immediately and as configured (conditional statements saved my life, no need to create lots of templates). The API documentation is also fantastic, plus the support team is really fast! 10 out of 10.
Roger S. -

Start sending now for free

Send your first email in minutes with a trial domain and subscribe to the Hobby plan for up to 3,000 emails/month free.

Frequently asked questions

How do I get started with MailerSend's Python SDK?

To get started with the Python SDK, sign up for a free account and create your API key. You can then install the MailerSend package using pip and use our Github documentation for code examples.

Is there a free tier for testing the API?

Yes, our free trial includes 100 emails and a demo domain you can use to quickly test out the API and sending functionality. 

How do I handle attachments in Python?

To add attachments to email messages, you need to set the attachment in your code. Check out our SDK documentation on sending an email with an attachment

Can I use MailerSend with popular Python web frameworks like Django or Flask?

Yes, you can use MailerSend with popular Python frameworks. 

How can I view errors?

You can configure you system to return the full response when you make a request or, if you have a Professional or Enterprise plan, you can view errors on the SMTP and API Logs page. 

What are the prerequisites for using the Python SDK?

To use the Python SDK, you’ll need Python 3.6.1 or higher, pip, a MailerSend account, and a MailerSend API key.

Can I use templates created in MailerSend with the Python SDK?

Yes, you can simply enter the template ID into your code. Find out more in our SDK documentation

How do I verify my sending domain?

You can add and verify domain via API or, from the dashboard, go to Email > Domains > Add domain. You cansave time and complete automatic domain authentication by following the steps, or verify your domain manually by adding the DNS records.