Skip to main content

E-mail with text and html content provided with markdown

Project description



Send e-mails with generated html content.

The content has to be written in Markdown syntax. The text part of the e-mail will be filled verbatim; the html part will be a converted HTML from the Markdown content.

E-mail rendering for the user (HTML part)


$ pip install markdownmail

Basic Usage

import markdownmail

CONTENT = u"""

This is a demo with a list:

1. Spam
2. Second spam
3. ...and eggs

email = markdownmail.MarkdownMail(
    subject=u'MarkdownMail demo',


Content must be unicode.

More infos

Additional informations are addable:

email = markdownmail.MarkdownMail(
    from_addr=(u'', u'Alice'),
    to_addr=(u'', u'Bob'),
    subject=u'MarkdownMail demo',

cc_addr and bcc_addr are optional. The from_addr, to_addr, cc_addr and bcc_addr parameters are the same as Enveloppe library.

Change SMTP port:

email.send("", port=3325)

Change SMTP login and password:

email.send("", login="user", password="password")

Use TLS:

email.send("", tls=True)


A default CSS is automatically added to the e-mail. It includes a font sans serif and minor improvements.

To override the default CSS, pass a string including the style to the css optional parameter of MardownMail:

import markdownmail

email = markdownmail.MarkdownMail(
    subject=u'MarkdownMail demo',
    css="font-family:monospace; color:green;"

Run tests

Tox is automatically installed in virtualenvs before executing the tests. Execute them with:

$ python test

Disable sending e-mails in your tests

The e-mail is not send if the parameter passed to send() method is an instance of NullServer.

email = markdownmail.MarkdownMail(


Assert about e-mails in your tests

Subclassing NullServer allows to provide a custom behaviour in the check() method:

class MyServer(markdownmail.NullServer):
    def check(self, email):
        assert u'' == email.to_addr[0]


Useful links

Envelopes library (MardownMail is a wrapper around Envelopes library.)

Markdown syntax

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

markdownmail-0.11.0.tar.gz (9.4 kB view hashes)

Uploaded Source

Built Distribution

markdownmail-0.11.0-py2.py3-none-any.whl (8.7 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page