{"id":16183736,"url":"https://github.com/yejianye/mdmail","last_synced_at":"2025-03-16T10:31:52.289Z","repository":{"id":57440449,"uuid":"110555030","full_name":"yejianye/mdmail","owner":"yejianye","description":"Send email written in Markdown","archived":false,"fork":false,"pushed_at":"2020-04-04T14:27:28.000Z","size":145,"stargazers_count":60,"open_issues_count":3,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-27T07:43:52.934Z","etag":null,"topics":["email","markdown","markdown-to-html","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yejianye.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-13T13:58:51.000Z","updated_at":"2025-02-17T01:54:37.000Z","dependencies_parsed_at":"2022-09-26T17:20:37.655Z","dependency_job_id":null,"html_url":"https://github.com/yejianye/mdmail","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yejianye%2Fmdmail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yejianye%2Fmdmail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yejianye%2Fmdmail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yejianye%2Fmdmail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yejianye","download_url":"https://codeload.github.com/yejianye/mdmail/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814895,"owners_count":20352036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email","markdown","markdown-to-html","python"],"created_at":"2024-10-10T07:06:26.457Z","updated_at":"2025-03-16T10:31:51.773Z","avatar_url":"https://github.com/yejianye.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Mdmail: Send emails written in Markdown\n=======================================\n\n[![Build Status](https://travis-ci.org/yejianye/mdmail.svg?branch=master)](https://travis-ci.org/yejianye/mdmail)\n[![Coverage Status](https://coveralls.io/repos/github/yejianye/mdmail/badge.svg)](https://coveralls.io/github/yejianye/mdmail)\n\nMdmail 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 mdmail viewed in Google Inbox\n\n\u003cimg src=\"screenshot.png\" height=\"640\"\u003e\u003c/img\u003e\n\nTo install mdmail\n\n```bash\n$ pip install mdmail\n```\n\nSend Email in Command-line\n--------------------------\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![Embed local image](../assets/image.jpg)\n```\n\nTo send this email with mdmail\n\n```bash\n$ mdmail sample_email.md\n```\n\nHere is an example of specifying subject, from/to in command-line\n\n```bash\n$ mdmail --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' | mdmail --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 `mdmail` command-line script\n\n```bash\nusage: mdmail [-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\nSend Email in Python Code\n--------------------------\n\nSending emails in python is straight-forward.\n\n```python\nimport mdmail\n\nemail=\"\"\"\n# Sample Email\n\n- Python is awesome\n- Markdown is cool\n\n![Embed local image](../assets/image.jpg)\n\"\"\"\n\nmdmail.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```\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\nmdmail.send(content, subject='Sample Email',\n            from_email='foo@example.com', to_email='bar@example.com',\n            smtp=smtp)\n```\n\n\n### API documentation `mdmail.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\nUse mdmail with Vim and Emacs\n-------------------------------\n\nSince `mdmail` can read from stdin and support email headers such as subject/from/to in the markdown file itself, integrating mdmail with Vim, Emacs or other text editors is easy.\n\nTo use mdmail in Vim, just write a markdown email with headers, and then execute `w !mdmail` command, which will send current buffer as stdin to mdmail.\n\nIn Emacs, you could write a small function to do the same thing\n\n```lisp\n(defun mdmail-send-buffer ()\n  (interactive)\n  (shell-command-on-region (point-min) (point-max) \"mdmail\"))\n```\n\nThen `M-x mdmail-send-buffer` will send current buffer to mdmail.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyejianye%2Fmdmail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyejianye%2Fmdmail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyejianye%2Fmdmail/lists"}