pigeon

Sending mails over HTTP.

npm install pigeon
4 downloads in the last week
5 downloads in the last month

Pigeon

Sending mails over HTTP. Pigeon can be used as a library and a command line tool.

Installation

Install with npm:

$ npm install pigeon

API

Creating the server:

var Pigeon = require('pigeon');
var server = new Pigeon(config, secret).server();
server.listen(8000);

Configuration

The Pigeon class accepts two parameters, config and secret.

config

config is an object contains several email services:

{
    gmail: {
        type: "SMTP",
        host: "smtp.gmail.com",
        port: 465,
        auth: {
            user: "gmail.user@gmail.com",
            pass: "userpass"
        }
    }
}

Find more on Nodemailer

Special Key Name:

  1. qq, we will send emails to qq users with this address
  2. gmail, we will send emails to gmail users with this address

Usage

Start an HTTP server with the command line:

$ pigeon -c config.js -p 8000 -s mysecret

Now send your emails with a POST request to the /send url path:

POST http://127.0.0.1:8000/send
Content-Type: application/json
X-Pigeon-Secret: mysecret

{
    "user": "someone@address.com",
    "title": "This is a testing email",
    "text": "Hello there"
}

Request Headers

  1. X-Pigeon-Secret: a secret token that is the same with your pigeon server
  2. Content-Type: content type must be in application/json

Request Body

The POST request payload should in JSON format. Required fields:

  1. user: the receiver's email address
  2. title: subject title of the email

Email content is also required, but it can be:

  1. text: a plain text email
  2. html: a html text email
  3. content: pigeon will render a html data from the given content

Optional fields:

  1. cc: cc field in email
  2. bcc: bcc field in email
  3. headers: email headers

Deploy to Heroku

You can create a new repo, and use pigeon as a dependency.

app.js:

var Pigeon = require('pigeon');
var server = new Pigeon({
    gmail: {
        service: "Gmail",
        sender: "Mr. Hook <someone@gmail.com>",
        auth: {
          user: "someone@gmail.com",
          pass: "password"
        }
  }
}, 'a-secret-token').server();
server.listen(process.env.PORT);

Procfile:

web: node app.js

License

MIT

npm loves you