wdsender
v1.0.0
Published
WildDuck mail sender
Downloads
1
Readme
WildDuck Email Sender
Preface
WDSender is a wrapper for WildDuck's email project. Link to WD official website. This package assumes you have a working copy of the WD and the credentials. We found it very useful to have an IMAP sever to connect to other apps. We hope you find this useful.
How to install
1.- Make a directory:
$ mkdir wdsender
$ cd wdsender
2.- Install from NPM
$ npm install wdsender
3.- Configure your own WildDuck instance in the module config.js file
var apiKey = 'your API Key'
var hostname = '127.0.0.1';
var port = 8080;
var path = '/users/5a85d50f6229e00598140f9f/submit';
var method = 'POST';
.- Here is an example using express:
create a file: wdsender_test.js
var wdsender = require('wdsender');
var express = require('express');
var bodyParser = require('body-parser');
var http = require('http');
var app = express();
app.use(bodyParser.json({limit: '50mb', parameterLimit:1000000}));
app.use(bodyParser.urlencoded({limit: '50mb', extended: true, parameterLimit:1000000}));
app.post('/mail', function(req, res) {
var from = req.body.from;
var to = req.body.to;
var sub = req.body.subject;
var msg = req.body.message;
var att = req.body.attachments;
wdsender(from,to,sub,msg,att);
res.setHeader('Content-Type', 'application/json');
//mimic a slow network connection
setTimeout(function(){
res.send(JSON.stringify({
From: from || null,
To: to || null,
Subject: sub || null,
Message: msg || null,
Attachments: att || null
}));
}, 1000)
});
var server = http.createServer(app);
var port = process.env.PORT || 3000;
server.listen(port);
console.log('http server listening on http://localhost:%d', port);
Usage to send an email:
You can use PostMan to test the module
Post data format to receive (raw):
{
"to": "[email protected]",
"from": "[email protected]",
"subject": "This is the subject",
"message": "This is the message",
"attachments": [{
"filename": "file.ext",
"content": "base64"
},
{
"filename": "file.ext",
"content": "base64"
}]
}
Enjoy!
License
Copyright 2018 Quad Tree
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Made with love at Quad Tree / SLP / Mexico
by: Manuel Garcia, Carlos Alvarez, Enrique Motilla visit our project at: https://erpcloud.mx
feb, 2018