Giter VIP home page Giter VIP logo

pigeon's Introduction

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: "[email protected]",
            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": "[email protected]",
    "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 <[email protected]>",
        auth: {
          user: "[email protected]",
          pass: "password"
        }
  }
}, 'a-secret-token').server();
server.listen(process.env.PORT);

Procfile:

web: node app.js

License

MIT

pigeon's People

Contributors

lepture avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.