Unlimited WordPress themes, graphics, videos & courses! Unlimited asset downloads! From $16.50/m
  1. Computer Skills
  2. Email

Send Email Newsletters via Command Line With Postman


If you're wanting to start a new email newsletter—or find a better way to send out your existing newsletter—there's quite a few tools for you. There's MailChimp and many other online email services, as well as tools built into Office apps like Word and Outlook's Mail Merge and a similar feature with new Google Docs add-ons. But if you're used to coding your own sites and using the terminal, there's a better option: the terminal app Postman.

In this tutorial, I'll show you how to effectively use Postman to send your email newsletters via any SMTP server: your own server or email account, or services like Amazon SES or Mandrill. We’ll cover creating a basic recipient list, creating a basic email template, different mail sending options, and finally what a full example looks like. With those building block examples under your belt, you'll be able to send any email newsletter the way you want.

Getting Started With Postman

This tutorial is going to assume you are comfortable installing support for the go programming language in your operating system environment and setting a couple path related environment variables.

I will briefly demonstrate how to get this up and running on your Mac, but please reference the documentation I linked to above before moving on—and note that you can get it running using similar steps on any Linux computer, and with a bit more effort on a Windows PC.

Installation on OS X

One prerequisite for installation on OS X is homebrew. Please read the documentation and setup homebrew before moving forward.

Now that you have homebrew all setup and up to date, run the brew command to install go. I’ll show all the output you should see below.

Now that you have go support installed, lets setup our environment.

To continue using postman or other utilities requiring go, we need to make these environment settings persistent. You’ll need to add them to your shell’s rc or profile file that gets loaded when launching a new terminal session. I’ve yet to join the ranks of the zsh folks full-time, so here’s what I put into my .bashrc after PATH is defined.

Now let’s install postman using go.

Run the postman command after installation completes, to verify you’ve done everything correctly. You should see the following output.

Creating a basic recipient list

The next thing you need is a list of contacts to send your email to. For our example you’ll need to create a blank text file named recipients.csv. In that text file you’ll enter “Email, Name, Type” on the first line, and then all of your contacts following that format, one per line. Be sure to save the file once you’re done checking that everything has been entered correctly.

Creating basic html & text email templates

Now that you have your list of email recipients created, let’s make two email templates that will hold our message. One template will be an html version and the other will be a text version to make plain text geeks like me happy. Feel free to deviate from copying and pasting my exact examples below. Play around with the wording and where you include the special “{{.Name}}” and “{{.Type}} entries. Those entries are ”variables" that will fill in the name and type from your recipients.csv contact list.

Here is about what your html version should look like:

Here is approximately what your plain text version should look like:

Sending options to consider

Now that you have all the required pieces assembled, there’s one more piece to consider before we start sending mail. For tutorial purposes, using your gmail or other personal account to send mail is just fine. When you put this into practice “in the real world” you’ll want to weigh some options.

At a minimum, be sure you’re sending mail from the account you want people to see when the recieve your message. I could think of far worse advice than having a special marketing@example.com or customerservice@example.com address to send such messages from. The other thing to consider is email limits imposed by your provider. There may be limits on how many different external email addresses you can send to in any one particular 24 hour period. If your list is 500 or less you’re likely to be fine using your current email service to send out a weekly email campaign. If you want to do much more than this using postman as a tool, I would seriously look into a service such as sendgridAmazon SES or Mandrill to send your emails. Just signup for an account with any of the respective services and use their server settings with postman.

Gathering a Few Technical Details

The last piece of the puzzle is gathering some information about the mail account you’re going to use to send your email. You’ll need to know the following items:

  • email address
  • server name (such as: smtp.example.com)
  • server port (such as: 587)
  • user name (usually your email address)
  • password

You will need these values handy before moving on and sending email.

Putting it All Together

Now let’s take all our work and do a live test. Run the same example I have below, substituting in your own information in place of mine. Be sure to pick a solid sounding subject line that matches the content of your message, but doesn’t send off sirens in a users head to reach straight for the delete button. You’re looking for the magic words “Emailed recipient X of X…” to appear, confirming your success. If postman just hangs indefinitely or you see another error, be sure to check your email server settings (user, password, server, port) again for any errors and then run postman again.

If everything worked on the command-line, wait for the emails to come in. You’ll know you followed our example correctly if you get the same email content, but the name and type fields were filled in appropriately with the values from your recipient list.

Example Email 1
Example email generated via postman

And another example, using the same email customized for another recipient:

Example Email 2
Example email generated via postman


With those building block examples under your belt, the possibilities are limitless. You can now spend time building some great reusable templates that you own and control, outside of any hosted marketing service. I highly recommend you stroll on over to Tuts+ web design for some great ideas on how to start building out and beautifying those templates.

If you have any further questions on using postman or are stuck and at your whit’s end; let me know in the comments below. As always, thanks for reading!

Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.