md-mailer
v0.0.8
Published
Send markdown emails from your command line.
Downloads
3
Readme
md-mailer
A simple tool to send markdown emails from the command line.
Installation
npm install -g md-mailer
Usage
md-mailer
allows one to write emails in markdown, it supports
embedded images and attachments.
To use it, first prepare your email:
---
from: John Appleseed <[email protected]>
to: Jack Bananapeel <[email protected]>, Sue Orangeskin <[email protected]>
cc: John Appleseed <[email protected]>
subject: An example email!
---
This is an example email! **Bold** text etc, it all works!
![an inline image](./image.jpg)
greets,
John
![an attached pdf](./document.pdf)
Just embed all the sending information in the frontmatter preamble of the email file.
To send the email, invoke md-mailer
:
md-mailer -u <user> -h <host> -p <pass> --ssl file.md
Markdown interpolation
Sometimes, you need to be able to insert variable text into your email. To allow this, md-mailer extends markdown with a little of custom syntax:
Hi my name is ${NAME},
Thanks,
$NAME
will replace the ${NAME}
and $NAME
variables with their value (found in
the environment). This also works for the frontmatter of your email:
---
to: $RECIPIENTS
from: $ME
subject: ${SUBJECT}
---
email...
Options
These can be passed as command line arguments, or as environment variables.
-h
, --host
, $MDMAILER_HOST
, option.host
The hostname of the mail server to use. (Example: smtp.gmail.com
).
-P
, --port
, $MDMAILER_PORT
, options.port
The port of the mail server.
-u
, --user
, $MDMAILER_USER
, options.user
The username of the account that should be used at the mail provider.
-p
, --pass
, $MDMAILER_PASS
, options.pass
The password of the account that should be used at the mail provider.
Note: using the command line arguments like this might be unsafe,
because the password will be stored cleatext in your shell history.
Prefer setting the environment variable $MDMAILER_PASS
.
--ssl
, options.ssl
If present, md-mailer
uses SSL.
-d
, --dry-run
If present, md-mailer
will not actually send any emails.
-?
. --help
Show the help text.
Header options
These options can be set from the email message header.
from
The sender of the message. Can be of the form Name <email@host>
or
email@host
.
to
A list of recipients to which the message will be sent.
You can enter a comma-separated list of emails (in the formats
described in from
) or use yamls list syntax:
to:
- Sue Orangeskin <[email protected]>
- [email protected]
is equivalent to
to: Sue Orangesking <[email protected]>, [email protected]
cc
, bcc
The list of carbon copy and blind carbon copy recipients, the format
used in to
is also valid here.
subject
The subject of the message.
Node API
You can also use the api from node:
import mdmailer from 'md-mailer'
mdmailer({
user: 'example'
, pass: '12345'
, host: 'smtp.gmail.com'
, ssl: true
, files: ['email1.md', 'email2.md' ]
});