A command-line tool to send e-mails via SMTP from the standard input.
Node.js 7 or above.
npm install -g pipe-mail
You can directly send an e-mail from the command line:
echo "Hello world!" | pipe-mail -s Subject -o smtp.fastmail.com -u myusername -p mypassword fromaddress@fastmail.com toaddress@fastmail.com
If you don't want to specify the server options every time, you can set them as environment variables:
export PIPEMAIL_SMTP_HOST=smtp.fastmail.com
export PIPEMAIL_SMTP_USER=myusername
export PIPEMAIL_SMTP_PASSWORD=mypassword
echo "Hello world!" | pipe-mail fromaddress@fastmail.com toaddress@fastmail.com
You can feed any file to it to send the content via e-mail:
echo "Hello world!" > email.txt
pipe-mail fromaddress@fastmail.com toaddress@fastmail.com < email.txt
$ pipe-mail --help
Usage: pipe-mail [options] [from-email-address] <recipient-email-address>
Options:
-V, --version output the version number
-s, --subject <subject> e-mail subject
-o, --host <host> SMTP server host
-r, --port <port> SMTP server port. Defaults to 485 if SSL is in use, 587 if not
-n, --no-ssl Don't use SSL when connecting to the SMTP server
-t, --html Send message as HTML
-u, --user <user> SMTP login username
-p, --password <password> SMTP login password
-h, --help output usage information
Some options can be specified via environment variables:
- PIPEMAIL_SMTP_HOST
- PIPEMAIL_SMTP_PORT
- PIPEMAIL_SMTP_USER
- PIPEMAIL_SMTP_PASSWORD
- PIPEMAIL_FROM : From e-mail address. If this is set, the "from-email-address" argument can be omitted
Feel free to report any issues or submit PRs via github
- Salvatore ZappalĂ - Initial work - @salvozappa
This project is licensed under the MIT License - see the LICENSE file for details
- This module is a wrapper around nodemailer, a comprehensive Node.js module to send e-mails
- This talk by Justin Searls (@searls) was source of inspiration for unit testing. The testdouble.js library makes the work straightforward
- Another nodemailer cli tool, nodemailer-cli was also source of inspiration