E-mail with text and html content provided with markdown
Project description
MarkdownMail
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
)
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("example.org", port=3325)
Change SMTP login and password:
email.send("example.org", login="user", password="password")
Use TLS:
email.send("example.org", tls=True)
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())
Useful links
Envelopes library (MardownMail is a wrapper around Envelopes library.)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file markdownmail-0.11.0.tar.gz
.
File metadata
- Download URL: markdownmail-0.11.0.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee3e9335647581eb7152b818d387baa499a86288870ad3f9097bb575bb794061 |
|
MD5 | b19260415d97b0258f9ff768d30712a0 |
|
BLAKE2b-256 | 17964e3bf15239b35415c39f74cfc40bfca564c740a528eca5bfb5dab89a7a88 |
File details
Details for the file markdownmail-0.11.0-py2.py3-none-any.whl
.
File metadata
- Download URL: markdownmail-0.11.0-py2.py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7735145ab54d9692ba5b0de8d67dd20f044d3689c6f166d7cace2a2427742e4c |
|
MD5 | 93f3c6e9932a58b2bf15f52612de0e83 |
|
BLAKE2b-256 | 3a23b2432adbde84ba6f5facbf5b059b81de752d584b9f6909949a8c3e3f4301 |