pigeon
v0.2.1
Published
Sending mails over HTTP.
Downloads
6
Readme
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:
- 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": "[email protected]",
"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 = 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