Name | nmdmail JSON |
Version |
0.5.0
JSON |
| download |
home_page | None |
Summary | Send emails written in Markdown |
upload_time | 2025-02-20 23:56:28 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
email
html
inline css
markdown
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# nMdmail: Send emails written in Markdown
Fork of https://github.com/yejianye/mdmail, which looks dead.
[](https://pypi.org/project/nmdmail)
[](https://github.com/nim65s/nmdmail/actions/workflows/test.yml)
[](https://results.pre-commit.ci/latest/github/nim65s/nmdmail/main)
[](https://codecov.io/gh/nim65s/nmdmail)
[](https://github.com/psf/black)
[](https://github.com/charliermarsh/ruff)
nMdmail sends emails written in Markdown. It could be used as a standalone command-line script or as a python module. The features includes
- Have a sane default CSS style and support CSS customization
- Support local images as inline images
Screenshot of an email sent via nmdmail viewed in Google Inbox
<img src="screenshot.png" height="640"></img>
To install nmdmail
```bash
$ python -m pip install nmdmail
```
## Send Email in Command-line
When sending emails from command-line, the body of the email could be read from a file or stdin.
Email headers such as subject, from/to, cc etc could be specified at the beginning of the markdown file, Or be specified in command-line arguments.
Here is an example of Markdown file with email headers
```
Subject: Sample Email
From: foo@xyz.com
To: bar@xyz.com
Cc: baz@xyz.com
# Sample Email
-

```
To send this email with nmdmail
```bash
$ nmdmail sample_email.md
```
Here is an example of specifying subject, from/to in command-line
```bash
$ nmdmail --from=foo@xyz.com --to=bar@xyz.com --subject='Sample' sample_email.md
```
To read email content from stdin,
```bash
$ echo '# Sample Email' | nmdmail --from=foo@xyz.com --to=bar@xyz.com --subject='Sample'
```
SMTP server configurations are read from the following environment variables
```bash
export MDMAIL_HOST="" # default: localhost
export MDMAIL_PORT="" # default: 25
export MDMAIL_USE_TLS="" # default: false
export MDMAIL_USE_SSL="" # default: false
export MDMAIL_USERNAME="" # default: None
export MDMAIL_PASSWORD="" # default: None
export MDMAIL_DEFAULT_SENDER="" # default: None
```
Full help of `nmdmail` command-line script
```bash
usage: nmdmail [-h] [--subject SUBJECT] [--from FROM_] [--to TO] [--cc CC]
[--bcc BCC] [--reply-to REPLY_TO] [--css CSS] [--print-only]
[file]
Send email written in Markdown.
positional arguments:
file Markdown file for email content. Default to STDIN.
optional arguments:
-h, --help show this help message and exit
--subject SUBJECT, -s SUBJECT
Subject line
--from FROM, -f FROM
From address
--to TO, -t TO To addresses, separated by comma
--cc CC, -c CC CC address, separated by comma
--bcc BCC, -b BCC Bcc address, separated by comma
--reply-to REPLY_TO, -r REPLY_TO
Reply-to address
--css CSS Use a custom CSS file
--print-only, -p Only print out rendered html
```
## Send Email in Python Code
Sending emails in python is straight-forward.
```python
import nmdmail
email="""
# Sample Email
- Python is awesome
- Markdown is cool

"""
nmdmail.send(email, subject='Sample Email',
from_email='foo@example.com', to_email='bar@example.com')
```
By default, it will use SMTP server on localhost. You could specify a SMTP server as well.
```python
# Specify SMTP server
smtp = {
'host: 'my-mailserver.com',
'port': 25,
'tls': False,
'ssl': False,
'user: '',
'password': '',
}
nmdmail.send(content,
subject='Sample Email',
from_email='foo@example.com',
to_email='bar@example.com',
smtp=smtp)
```
### API documentation `nmdmail.send`
- **email** (str/obj): A markdown string or EmailContent object
- **subject** (str): subject line
- **from_email** (str): sender email address
- **to_email** (str/list): recipient email addresses
- **cc** (str/list): CC email addresses (string or a list)
- **bcc** (str/list): BCC email addresses (string or a list)
- **reply_to** (str): Reply-to email address
- **smtp** (dict): SMTP configuration with following keys
- *host* (str): SMTP server host. Default: localhost
- *port* (int): SMTP server port. Default: 25
- *tls* (bool): Use TLS. Default: False
- *ssl* (bool): Use SSL. Default: False
- *user* (bool): SMTP login user. Default empty
- *password* (bool): SMTP login password. Default empty
## Use nmdmail with Vim and Emacs
Since `nmdmail` can read from stdin and support email headers such as subject/from/to in the markdown file itself,
integrating nmdmail with Vim, Emacs or other text editors is easy.
To use nmdmail in Vim, just write a markdown email with headers, and then execute `w !nmdmail` command, which will send
current buffer as stdin to nmdmail.
In Emacs, you could write a small function to do the same thing
```lisp
(defun nmdmail-send-buffer ()
(interactive)
(shell-command-on-region (point-min) (point-max) "nmdmail"))
```
Then `M-x nmdmail-send-buffer` will send current buffer to nmdmail.
Raw data
{
"_id": null,
"home_page": null,
"name": "nmdmail",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "email, html, inline css, markdown",
"author": null,
"author_email": "Guilhem Saurel <guilhem.saurel@laas.fr>, Jianye Ye <yejianye@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/c3/c8/2fcff532c1b1fa5243be96e25d62d480f28f7440e7582cf2e70a84dcd5b3/nmdmail-0.5.0.tar.gz",
"platform": null,
"description": "# nMdmail: Send emails written in Markdown\n\nFork of https://github.com/yejianye/mdmail, which looks dead.\n\n[](https://pypi.org/project/nmdmail)\n[](https://github.com/nim65s/nmdmail/actions/workflows/test.yml)\n[](https://results.pre-commit.ci/latest/github/nim65s/nmdmail/main)\n[](https://codecov.io/gh/nim65s/nmdmail)\n[](https://github.com/psf/black)\n[](https://github.com/charliermarsh/ruff)\n\n\nnMdmail sends emails written in Markdown. It could be used as a standalone command-line script or as a python module. The features includes\n\n- Have a sane default CSS style and support CSS customization\n- Support local images as inline images\n\nScreenshot of an email sent via nmdmail viewed in Google Inbox\n\n<img src=\"screenshot.png\" height=\"640\"></img>\n\nTo install nmdmail\n\n```bash\n$ python -m pip install nmdmail\n```\n\n## Send Email in Command-line\n\nWhen sending emails from command-line, the body of the email could be read from a file or stdin.\n\nEmail headers such as subject, from/to, cc etc could be specified at the beginning of the markdown file, Or be specified in command-line arguments.\n\nHere is an example of Markdown file with email headers\n\n```\nSubject: Sample Email\nFrom: foo@xyz.com\nTo: bar@xyz.com\nCc: baz@xyz.com\n\n# Sample Email\n\n-\n\n\n```\n\nTo send this email with nmdmail\n\n```bash\n$ nmdmail sample_email.md\n```\n\nHere is an example of specifying subject, from/to in command-line\n\n```bash\n$ nmdmail --from=foo@xyz.com --to=bar@xyz.com --subject='Sample' sample_email.md\n```\n\nTo read email content from stdin,\n\n```bash\n$ echo '# Sample Email' | nmdmail --from=foo@xyz.com --to=bar@xyz.com --subject='Sample'\n```\n\nSMTP server configurations are read from the following environment variables\n\n```bash\nexport MDMAIL_HOST=\"\" # default: localhost\nexport MDMAIL_PORT=\"\" # default: 25\nexport MDMAIL_USE_TLS=\"\" # default: false\nexport MDMAIL_USE_SSL=\"\" # default: false\nexport MDMAIL_USERNAME=\"\" # default: None\nexport MDMAIL_PASSWORD=\"\" # default: None\nexport MDMAIL_DEFAULT_SENDER=\"\" # default: None\n```\n\nFull help of `nmdmail` command-line script\n\n```bash\nusage: nmdmail [-h] [--subject SUBJECT] [--from FROM_] [--to TO] [--cc CC]\n [--bcc BCC] [--reply-to REPLY_TO] [--css CSS] [--print-only]\n [file]\n\nSend email written in Markdown.\n\npositional arguments:\n file Markdown file for email content. Default to STDIN.\n\noptional arguments:\n -h, --help show this help message and exit\n --subject SUBJECT, -s SUBJECT\n Subject line\n --from FROM, -f FROM\n From address\n --to TO, -t TO To addresses, separated by comma\n --cc CC, -c CC CC address, separated by comma\n --bcc BCC, -b BCC Bcc address, separated by comma\n --reply-to REPLY_TO, -r REPLY_TO\n Reply-to address\n --css CSS Use a custom CSS file\n --print-only, -p Only print out rendered html\n```\n\n## Send Email in Python Code\n\nSending emails in python is straight-forward.\n\n```python\nimport nmdmail\n\nemail=\"\"\"\n# Sample Email\n\n- Python is awesome\n- Markdown is cool\n\n\n\"\"\"\n\nnmdmail.send(email, subject='Sample Email',\n from_email='foo@example.com', to_email='bar@example.com')\n```\n\nBy default, it will use SMTP server on localhost. You could specify a SMTP server as well.\n\n```python\n# Specify SMTP server\nsmtp = {\n 'host: 'my-mailserver.com',\n 'port': 25,\n 'tls': False,\n 'ssl': False,\n 'user: '',\n 'password': '',\n}\n\nnmdmail.send(content,\n subject='Sample Email',\n from_email='foo@example.com',\n to_email='bar@example.com',\n smtp=smtp)\n```\n\n\n### API documentation `nmdmail.send`\n\n- **email** (str/obj): A markdown string or EmailContent object\n- **subject** (str): subject line\n- **from_email** (str): sender email address\n- **to_email** (str/list): recipient email addresses\n- **cc** (str/list): CC email addresses (string or a list)\n- **bcc** (str/list): BCC email addresses (string or a list)\n- **reply_to** (str): Reply-to email address\n- **smtp** (dict): SMTP configuration with following keys\n - *host* (str): SMTP server host. Default: localhost\n - *port* (int): SMTP server port. Default: 25\n - *tls* (bool): Use TLS. Default: False\n - *ssl* (bool): Use SSL. Default: False\n - *user* (bool): SMTP login user. Default empty\n - *password* (bool): SMTP login password. Default empty\n\n## Use nmdmail with Vim and Emacs\n\nSince `nmdmail` can read from stdin and support email headers such as subject/from/to in the markdown file itself,\nintegrating nmdmail with Vim, Emacs or other text editors is easy.\n\nTo use nmdmail in Vim, just write a markdown email with headers, and then execute `w !nmdmail` command, which will send\ncurrent buffer as stdin to nmdmail.\n\nIn Emacs, you could write a small function to do the same thing\n\n```lisp\n(defun nmdmail-send-buffer ()\n (interactive)\n (shell-command-on-region (point-min) (point-max) \"nmdmail\"))\n```\n\nThen `M-x nmdmail-send-buffer` will send current buffer to nmdmail.\n",
"bugtrack_url": null,
"license": null,
"summary": "Send emails written in Markdown",
"version": "0.5.0",
"project_urls": null,
"split_keywords": [
"email",
" html",
" inline css",
" markdown"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "93e0798ebb0c8b082e077712e2958ba5d714f835841f61a12c5d00dfde532d71",
"md5": "d6b15483b640b89b7e55b362703a7e41",
"sha256": "8c4d506cad6ee731710d520891453ae66eee2af5d90af5dca1cdad8358973121"
},
"downloads": -1,
"filename": "nmdmail-0.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d6b15483b640b89b7e55b362703a7e41",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 8145,
"upload_time": "2025-02-20T23:56:27",
"upload_time_iso_8601": "2025-02-20T23:56:27.037090Z",
"url": "https://files.pythonhosted.org/packages/93/e0/798ebb0c8b082e077712e2958ba5d714f835841f61a12c5d00dfde532d71/nmdmail-0.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "c3c82fcff532c1b1fa5243be96e25d62d480f28f7440e7582cf2e70a84dcd5b3",
"md5": "ba3f7a11b38c536ebce63e02eeefabeb",
"sha256": "82c0be32fe5c3b4b765fdf9054bd4742319276fc46866d860deb4918443fb5f6"
},
"downloads": -1,
"filename": "nmdmail-0.5.0.tar.gz",
"has_sig": false,
"md5_digest": "ba3f7a11b38c536ebce63e02eeefabeb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 161476,
"upload_time": "2025-02-20T23:56:28",
"upload_time_iso_8601": "2025-02-20T23:56:28.521265Z",
"url": "https://files.pythonhosted.org/packages/c3/c8/2fcff532c1b1fa5243be96e25d62d480f28f7440e7582cf2e70a84dcd5b3/nmdmail-0.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-20 23:56:28",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "nmdmail"
}