Package: nmdmail
nMdmail: Send emails written in MarkdownFork ofhttps://github.com/yejianye/mdmail, which looks dead.nMdmail sends emails written in Markdown. It could be used as a standalone command-line script or as a python module. The features includesHave a sane default CSS style and support CSS customizationSupport local images as inline imagesScreenshot of an email sent via nmdmail viewed in Google InboxTo install nmdmail$python-mpipinstallnmdmailSend Email in Command-lineWhen 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 headersSubject: Sample Email
From: foo@xyz.com
To: bar@xyz.com
Cc: baz@xyz.com

# Sample Email

-

![Embed local image](../assets/image.jpg)To send this email with nmdmail$nmdmailsample_email.mdHere is an example of specifying subject, from/to in command-line$nmdmail--from=foo@xyz.com--to=bar@xyz.com--subject='Sample'sample_email.mdTo read email content from stdin,$echo'# Sample Email'|nmdmail--from=foo@xyz.com--to=bar@xyz.com--subject='Sample'SMTP server configurations are read from the following environment variablesexportMDMAIL_HOST=""# default: localhostexportMDMAIL_PORT=""# default: 25exportMDMAIL_USE_TLS=""# default: falseexportMDMAIL_USE_SSL=""# default: falseexportMDMAIL_USERNAME=""# default: NoneexportMDMAIL_PASSWORD=""# default: NoneexportMDMAIL_DEFAULT_SENDER=""# default: NoneFull help ofnmdmailcommand-line scriptusage:nmdmail[-h][--subjectSUBJECT][--fromFROM_][--toTO][--ccCC][--bccBCC][--reply-toREPLY_TO][--cssCSS][--print-only][file]SendemailwritteninMarkdown.

positionalarguments:fileMarkdownfileforemailcontent.DefaulttoSTDIN.

optionalarguments:-h,--helpshowthishelpmessageandexit--subjectSUBJECT,-sSUBJECTSubjectline--fromFROM,-fFROMFromaddress--toTO,-tTOToaddresses,separatedbycomma--ccCC,-cCCCCaddress,separatedbycomma--bccBCC,-bBCCBccaddress,separatedbycomma--reply-toREPLY_TO,-rREPLY_TOReply-toaddress--cssCSSUseacustomCSSfile--print-only,-pOnlyprintoutrenderedhtmlSend Email in Python CodeSending emails in python is straight-forward.importnmdmailemail="""# Sample Email- Python is awesome- Markdown is cool![Embed local image](../assets/image.jpg)"""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.# Specify SMTP serversmtp={'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 documentationnmdmail.sendemail(str/obj): A markdown string or EmailContent objectsubject(str): subject linefrom_email(str): sender email addressto_email(str/list): recipient email addressescc(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 addresssmtp(dict): SMTP configuration with following keyshost(str): SMTP server host. Default: localhostport(int): SMTP server port. Default: 25tls(bool): Use TLS. Default: Falsessl(bool): Use SSL. Default: Falseuser(bool): SMTP login user. Default emptypassword(bool): SMTP login password. Default emptyUse nmdmail with Vim and EmacsSincenmdmailcan 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 executew !nmdmailcommand, which will send
current buffer as stdin to nmdmail.In Emacs, you could write a small function to do the same thing(defunnmdmail-send-buffer()(interactive)(shell-command-on-region(point-min)(point-max)"nmdmail"))ThenM-x nmdmail-send-bufferwill send current buffer to nmdmail.