Skip to main content

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.

E-mail rendering for the user (HTML part)

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.

Change SMTP port:

email.send("example.org", port=3325)

Change SMTP login and password:

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

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())

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.8.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

markdownmail-0.8.0-py2.py3-none-any.whl (8.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file markdownmail-0.8.0.tar.gz.

File metadata

  • Download URL: markdownmail-0.8.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.7.9

File hashes

Hashes for markdownmail-0.8.0.tar.gz
Algorithm Hash digest
SHA256 289e66ae26e85c9995dbb2929f0f179cb46fba5c06778a8663167c0036c15cfa
MD5 c69cf5773533c58df80525843ac8f8ca
BLAKE2b-256 0d68116a3ee932ca1b825fd3411028d3cc6f9293fabbda657f95f8860df33be8

See more details on using hashes here.

File details

Details for the file markdownmail-0.8.0-py2.py3-none-any.whl.

File metadata

  • Download URL: markdownmail-0.8.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.7.9

File hashes

Hashes for markdownmail-0.8.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1e09bcc5916077f36925e9f24f42964aedc5b3ab0649690637c86412adf13036
MD5 03b221c2fd728954f9fb0ac14394e490
BLAKE2b-256 82f28f6708e37995a6e76c76a70a078019fedecd540c41798aa0f39d4c268f5c

See more details on using hashes here.

Supported by

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