Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

E-mail with text and html content provided with markdown

Project Description

Purpose

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.

Install

$ pip install markdownmail

Basic Usage

import markdownmail

CONTENT = u"""
SPAMS AND EGGS
==============

This is a demo with a list:

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

email = markdownmail.MarkdownMail(
    from_addr=u'alice@example.org',
    to_addr=u'bob@example.org',
    subject=u'MarkdownMail demo',
    content=CONTENT
)

email.send('localhost')

Content must be unicode.

More infos

Additional informations are addable:

email = markdownmail.MarkdownMail(
    from_addr=(u'alice@example.org', u'Alice'),
    to_addr=(u'bob@example.org', u'Bob'),
    subject=u'MarkdownMail demo',
    content=CONTENT
)

The from_addr and to_addr parameters are the same as Enveloppe library.

Style

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(
    from_addr=u'alice@example.org',
    to_addr=u'bob@example.org',
    subject=u'MarkdownMail demo',
    content="CONTENT",
    css="font-family:monospace; color:green;"
)

Run tests

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

$ python setup.py 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(
    #params
)

email.send(markdownmail.NullServer())

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'bob@example.org' == email.to_addr[0]

email.send(MyServer())
Release History

Release History

This version
History Node

0.5.0

History Node

0.4.2

History Node

0.4.1

History Node

0.4.0

History Node

0.3.1

History Node

0.3.0

History Node

0.2.1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
markdownmail-0.5.0-py2.py3-none-any.whl (9.4 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Apr 25, 2017
markdownmail-0.5.0.tar.gz (6.7 kB) Copy SHA256 Checksum SHA256 Source Apr 25, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting