Easily send mail, even HTML emails, from the command line using the Mailgun API.
npm install mailgun-send-cli -g
Note, this uses mailgun.js under the hood, which requires node.js >= 12.x. If you are using an older version of node, consider using an older version of this package. Version 0.2.0 requires node >=8, while version 0.1.4 requires node >=4.3.2.
npm install [email protected] -g
mailgun-send [options]
You will be prompted to enter your Mailgun API Key and domain on your first use. These values will be used on every subsequent call until the --reset
flag is used to reset them.
Plain text email:
mailgun-send -f [email protected] -t [email protected] -s 'Email sent via Mailgun from the command line' -T 'Hello there! The mailgun-send-cli tool is really cool. You should check it out!'
HTML email:
mailgun-send -f [email protected] -t [email protected] -s 'HTML Email sent via Mailgun from the command line' -H ~/path/to/html/file.html
Subject of Email. Required.
Email address of recipient of email. Required.
Email address of email sender. Required.
ReplyTo email address. Optional.
Email address to CC. Optional.
Email address to BCC. Optional.
Text to send as body of email. Must specify this or --htmlpath
.
Path to HTML file to send as email. Must specify this or --text
.
Reset Mailgun API key and Domain. You will be prompted to enter these again.
Output usage information
Output the version number
Output more detailed information, such as message id
If it says your email was successfully sent, but you don't see the email in your inbox, check the logs of your mailgun account for more information.
Be sure to use a verified domain to remove the "sent via Mailgun.org" message from your emails and increase your monthly free send limit from 300 to 10,000.
See Mailgun's FAQ's for more information.