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 = ;var server = config secret;server;
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:
- qq, we will send emails to qq users with this address
- 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
- X-Pigeon-Secret: a secret token that is the same with your pigeon server
- Content-Type: content type must be in
application/json
Request Body
The POST
request payload should in JSON format. Required fields:
- user: the receiver's email address
- title: subject title of the email
Email content is also required, but it can be:
- text: a plain text email
- html: a html text email
- content: pigeon will render a html data from the given content
Optional fields:
- cc: cc field in email
- bcc: bcc field in email
- headers: email headers
Deploy to Heroku
You can create a new repo, and use pigeon as a dependency.
app.js:
var Pigeon = ;var server = gmail: service: "Gmail" sender: "Mr. Hook <someone@gmail.com>" auth: user: "someone@gmail.com" pass: "password" 'a-secret-token';server;
Procfile:
web: node app.js
License
MIT