npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mailgun-mate

v0.1.6

Published

CLI to work with mailgun

Downloads

24

Readme

Install

npm i mailgun-mate -g

Or:

git clone [email protected]:binarymist/mailgun-mate.git && cd mailgun-mate && npm install

Before running, you'll need to setup a little configuration. See the Configuration section below.

Quick Start

First, you need to have a free mailgun account, a domain setup there, and at least one mail list to start controlling.

Configuration

This project uses convict. The configuration file(s) are in ./config/. You will need to provide one according to the NODE_ENV environment variable you are running mailgun-mate with. First find where mailgun-mate is installed to with whereis mailgun-mate. This command will show where the bin file is, from there, you just need to ascend the directories until you find a lib/node_modules/mailgun-mate/config/ directory. From there, you can copy the config.example.json file and rename it to config.[your-environment].json (your-environment should be development, production, or what ever you set NODE_ENV to).

Decide on a directory that you will put your text files containing HTML (although just text is also fine), and assign that directory path to your config file's emailBodyFileDir property.
In your HTML mailout files, you can add an unsubscribe link

Mailgun provides the ability for you to have them insert an unsubscribe link into all emails sent from your your domain. This link allows the email receiver to unsubscribe from the specific list that the email was sent from.
In many cases you wont want an unsubscribe link, like when sending immediately or scheduling a small batch of custom mailouts from a large list of say business contacts, as these are usually fairly personal.
The only option I've found that works on a email by email basis is inserting the following:

<a href="%unsubscribe_url%">unsubscribe from domain</a> <!--This link unsubscribes the member from the entire domain.-->

Clicking on that will unsubscribe the list member from the entire domain, which is usually not what you may want, especially if you have many lists.

Before sending any batch, I like to make sure I have o:testmode set to true, and I'm targeting a test emailList. Both of these can be set in the config file(s), but are also overrideable at the command line.
you can change these once you're confident your configuration, command line args, email teamplate, and recipient variables are correct.
I usually use a first name (fname in my case), then build up your email teamplate using a %recipient.fname% wich mailgun will substitute for the fname property you set in the list members recipient variables. The following is an example of how I setup the mailgun recipient variables.

{
  "fname": "Bob",
  "mailgunMateScheduledSends": [
    [
      "a.html",
      "2018-06-16_17:00:00"
    ],
    [
      "b.html",
      "2018-06-16_17:10:00"
    ]
  ],
  "name": "Bob Builder",
  "org": "Bob Builder Holdings",
  "role": "Carpenter"
}

The mailgunMateScheduledSends is what mailgun-mate adds for you. Each time you schedule an email, a new array containing the email-body-file and the schedule-time will be added to the mailgunMateScheduledSends array. Mailgun-mate knows where to find theemail-body-file due to the emailBodyFileDir that you need to set in the configuration file.

The name property is printed beside the email address in mailgun-mate. org and role will be used to sort in the future.

Usage

Command Line

Usage: mailgun-mate [command(s)] [option(s)]

Options:
  -a, --about               Show about screen.
  -v, --version             Show version number.
  -h, --help                Show help.

Commands:
  schedule-delivery         Launch scheduled mail delivery, max of three days in advance.

Options:
  -l, --email-list      <email-list>                     The mailgun email list you would like to use.
  -b, --email-body-file <email-body-file>                File containing the html for the body of the email. Relative to the emailBodyFileDir directory you set in the configuration.
  -f, --from <sent-from-for-replies>                     The value that the receiver will see that your emails appear to be sent from, in the form of "Kim <[email protected]>"
  -s, --subject <subject-for-email>'                     The subject for the email
  -t, --schedule-time <time-to-schedule-email-send-for>  The time that all emails will be sent (in RFC 2822 time).
  -tm, --test-mode                                       Whether or not to send in test mode "o:testmode". defaultValue set in config file.

Options:
  -h, --help                     Show help.

Commands:
  schedule-delivery list         List members in order based on latest or oldest mailgunMateScheduledSends datetimes.

Options:
  -h, --help                                    Show help.
  -l, --email-list          <email-list>        The mailgun email list you would like to use. A required string argument, if none is present on command line, value from config file is used.
  -o, --order              [des|asc(default)]   The order you would like the items displayed in.

Before authenticating with mailgun, mailgun-mate checks the ${os.homedir()}/.mailgun/key for your private key, if present, it will attempt authentication, if not present, it will prompt for your key at the terminal. Currently there is no validation on your private key file ownership or permissions, but they should be set at least as restrictive as SSH private keys.

Debugging

From within your mailgun-mate source directory, run the following and open your chrome dev tools:

node --inspect-brk ./bin/mailgun-mate [command(s)] [option(s)]

Or

npm run debug

If you need to pass arguments:

npm run debug -- [command(s)] [option(s)]

Contribution

Please open an issue to discus the proposed change before submitting a pull request.

Questions

If you have any questions around the installation, configuration or running of mailgun-mate, please submit an issue.

License

Copyright Kim Carter and other contributors, Licensed under MIT.