Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

maildev

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

maildev - npm Package Compare versions

Comparing version 0.9.1 to 0.10.0

lib/auth.js

11

app/scripts/app.js

@@ -51,8 +51,7 @@ /* global angular, io */

var sidebar = document.querySelector('.sidebar')
, sidebarHeader = document.querySelector('.sidebar-header')
, emailList = document.querySelector('.email-list')
, sidebarHeaderHeight = sidebarHeader.getBoundingClientRect().height
, resizeTimeout = null
;
var sidebar = document.querySelector('.sidebar');
var sidebarHeader = document.querySelector('.sidebar-header');
var emailList = document.querySelector('.email-list');
var sidebarHeaderHeight = sidebarHeader.getBoundingClientRect().height;
var resizeTimeout = null;

@@ -59,0 +58,0 @@ function adjustEmailListHeight(){

@@ -11,11 +11,6 @@ /* global angular, app */

var iframe = null
, getItem
, prepIframe
, fixIframeHeight
, replaceMediaQueries;
var iframe = null;
// Get the item data by route parameter
getItem = function() {
var getItem = function() {

@@ -42,6 +37,7 @@ Email.get({ id: $routeParams.itemId }, function(email) {

// Prepares the iframe for interaction
prepIframe = function() {
var prepIframe = function() {
// Wait for iframe to load
setTimeout(function() {
var baseEl, head;
var baseEl;
var head;

@@ -55,4 +51,3 @@ iframe = document.getElementsByTagName('iframe')[0];

if (head)
head.appendChild(baseEl);
if (head) head.appendChild(baseEl);

@@ -69,6 +64,6 @@ replaceMediaQueries();

// This prevents the iframe from having scrollbars
fixIframeHeight = function() {
var fixIframeHeight = function() {
var body = iframe.contentDocument.getElementsByTagName('body')[0]
, newHeight = body.scrollHeight;
var body = iframe.contentDocument.getElementsByTagName('body')[0];
var newHeight = body.scrollHeight;

@@ -79,3 +74,3 @@ iframe.height = newHeight;

// Updates all media query rules to use 'width' instead of device width
replaceMediaQueries = function(){
var replaceMediaQueries = function(){
angular.forEach(iframe.contentDocument.styleSheets, function(styleSheet){

@@ -125,6 +120,19 @@ angular.forEach(styleSheet.cssRules, function(rule){

Email.delete({ id: item.id }, function(email) {
$rootScope.$emit('Refresh');
$location.path('/');
var idx = $scope.items.reduce(function(p, c, i){
if (p !== 0) return p;
return c.id === item.id ? i : 0;
}, 0);
var nextIdx = $scope.items.length === 1 ? null :
idx === 0 ? idx + 1 : idx - 1;
if (nextIdx !== null) {
$location.path('/email/' + $scope.items[nextIdx].id);
} else {
$location.path('/');
}
$scope.items.splice(idx, 1);
});
};

@@ -131,0 +139,0 @@

@@ -9,9 +9,9 @@

var program = require('commander')
, pkg = require('./package.json')
, web = require('./lib/web')
, mailserver = require('./lib/mailserver')
, logger = require('./lib/logger')
;
var program = require('commander');
var pkg = require('./package.json');
var web = require('./lib/web');
var mailserver = require('./lib/mailserver');
var logger = require('./lib/logger');
module.exports = function(config) {

@@ -25,9 +25,14 @@

.version(version)
.option('-s, --smtp [port]', 'SMTP port to catch emails [1025]', '1025')
.option('-w, --web [port]', 'Port to run the Web GUI [1080]', '1080')
.option('-s, --smtp <port>', 'SMTP port to catch emails [1025]', '1025')
.option('-w, --web <port>', 'Port to run the Web GUI [1080]', '1080')
.option('--ip <ip address>', 'IP Address to bind services to', '0.0.0.0')
.option('--outgoing-host <host>', 'SMTP host for outgoing emails')
.option('--outgoing-port <port>', 'SMTP port for outgoing emails')
.option('--outgoing-user <user>', 'SMTP user for outgoing emails')
.option('--outgoing-pass <pass>', 'SMTP password for outgoing emails')
.option('--outgoing-pass <password>', 'SMTP password for outgoing emails')
.option('--outgoing-secure', 'Use SMTP SSL for outgoing emails')
.option('--incoming-user <user>', 'SMTP user for incoming emails')
.option('--incoming-pass <pass>', 'SMTP password for incoming emails')
.option('--web-user <user>', 'HTTP user for GUI')
.option('--web-pass <password>', 'HTTP password for GUI')
.option('-o, --open', 'Open the Web GUI after startup')

@@ -43,25 +48,24 @@ .option('-v, --verbose')

// Start the Mailserver & Web GUI
mailserver.listen( config.smtp );
if (
config.outgoingHost ||
mailserver.create(config.smtp, config.ip, config.incomingUser, config.incomingPass);
if (config.outgoingHost ||
config.outgoingPort ||
config.outgoingUser ||
config.outgoingPass ||
config.outgoingSecure) {
mailserver.setupOutgoing(
config.outgoingHost,
parseInt(config.outgoingPort),
config.outgoingUser,
config.outgoingPass,
config.outgoingSecure
){
mailserver.setupOutgoing(
config.outgoingHost
, parseInt(config.outgoingPort)
, config.outgoingUser
, config.outgoingPass
, config.outgoingSecure
);
}
web.listen( config.web );
logger.info('MailDev app running at 127.0.0.1:%s', config.web);
web.start(config.web, config.ip, mailserver, config.webUser, config.webPass);
if (config.open){
var open = require('open');
open('http://localhost:' + config.web);
open('http://' + (config.ip === '0.0.0.0' ? 'localhost' : config.ip) + ':' + config.web);
}

@@ -68,0 +72,0 @@

@@ -6,17 +6,16 @@

var simplesmtp = require('simplesmtp')
, MailParser = require('mailparser').MailParser
, events = require('events')
, logger = require('./logger')
, fs = require('fs')
, os = require('os')
, path = require('path')
;
var simplesmtp = require('simplesmtp');
var MailParser = require('mailparser').MailParser;
var events = require('events');
var logger = require('./logger');
var fs = require('fs');
var os = require('os');
var path = require('path');
var defaultPort = 1025
, store = []
, tempDir = path.join(os.tmpdir(), 'maildev', process.pid.toString())
, eventEmitter = new events.EventEmitter()
, smtp
;
var defaultPort = 1025;
var defaultHost = '0.0.0.0';
var store = [];
var tempDir = path.join(os.tmpdir(), 'maildev', process.pid.toString());
var eventEmitter = new events.EventEmitter();
var smtp;

@@ -44,5 +43,4 @@

function makeId(){
var text = ''
, possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
;
var text = '';
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

@@ -166,14 +164,34 @@ for (var i = 0; i < 8; i++){

/**
* Authorize callback for smtp server
*/
function authorizeUser(conn, username, password, callback) {
if (username === this.options.incomingUser &&
password === this.options.incomingPassword) {
callback(null, true);
} else {
callback(new Error('Auth fail!'), false);
}
}
/**
* Start the mailServer
* Create and configure the mailserver
*/
mailServer.listen = function(port){
mailServer.create = function(port, host, user, password) {
// Start the server & Disable DNS checking
smtp = simplesmtp.createServer({
disableDNSValidation: true
disableDNSValidation: true,
requireAuthentication: !!(user && password),
incomingUser: user,
incomingPassword: password
});
if (user && password) {
smtp.on('authorizeUser', authorizeUser);
}
// Setup temp folder for attachments

@@ -183,9 +201,14 @@ createTempFolder();

mailServer.port = port || defaultPort;
mailServer.host = host || defaultHost;
};
// Listen on the specified port
smtp.listen(port, function(err){
if (err) throw err;
logger.info('MailDev SMTP Server running at 127.0.0.1:%s', mailServer.port);
});
/**
* Start the mailServer
*/
mailServer.listen = function(callback) {
if (typeof callback !== 'function') callback = null;
// Bind events to stream

@@ -195,4 +218,20 @@ smtp.on('startData', newStream);

smtp.on('dataReady', endStream);
// Listen on the specified port
smtp.listen(mailServer.port, mailServer.host, function(err) {
if (err) {
if (callback) {
callback(err);
} else {
throw err;
}
}
if (callback) callback();
logger.info('MailDev SMTP Server running at %s:%s', mailServer.host, mailServer.port);
});
};
/**

@@ -213,5 +252,6 @@ * Stop the mailserver

mailServer.on = eventEmitter.on.bind(eventEmitter);
mailServer.emit = eventEmitter.emit.bind(eventEmitter);
mailServer.removeListener = eventEmitter.removeListener.bind(eventEmitter);
mailServer.on = eventEmitter.on.bind(eventEmitter);
mailServer.emit = eventEmitter.emit.bind(eventEmitter);
mailServer.removeListener = eventEmitter.removeListener.bind(eventEmitter);
mailServer.removeAllListeners = eventEmitter.removeAllListeners.bind(eventEmitter);

@@ -265,4 +305,4 @@

mailServer.deleteEmail = function(id, done){
var email = null
, emailIndex = null;
var email = null;
var emailIndex = null;

@@ -354,6 +394,6 @@ store.forEach(function(element, index){

var options = {
secureConnection: secure
, maxMessages: 1
, debug: true
};
secureConnection: secure,
maxMessages: 1,
debug: true
};

@@ -439,6 +479,6 @@ if (pass && user) {

var filename = email.id + ".eml";
var filename = email.id + '.eml';
done(null, 'message/rfc822', filename, fs.createReadStream(path.join(tempDir, id + '.eml')));
});
};
};

@@ -6,164 +6,58 @@

var express = require('express')
, app = express()
, server = require('http').createServer(app)
, io = require('socket.io').listen(server)
, pkg = require('../package.json')
, mailserver = require('./mailserver')
;
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io').listen(server);
var routes = require('./routes');
var auth = require('./auth');
var logger = require('./logger');
/**
* Exports
* WebSockets
*/
module.exports = server;
function emitNewMail(socket) {
return function(email) {
socket.emit('newMail', email);
};
}
app.use('/', express.static(__dirname + '../../app'));
function webSocketConnection(mailserver) {
return function onConnection(socket) {
// When a new email arrives, the 'new' event will be emitted
mailserver.on('new', emitNewMail(socket));
socket.on('disconnect', function(){
mailserver.removeListener('new', emitNewMail(socket));
});
};
}
/**
* Requests
* Start the web server
*/
// Get all emails
app.get('/email', function(req, res){
module.exports.start = function(port, host, mailserver, user, password) {
mailserver.getAllEmail(function(err, emailList){
if (err) return res.status(404).json([]);
if (user && password) {
app.use(auth(user, password));
}
app.use('/', express.static(__dirname + '../../app'));
routes(app, mailserver);
res.json(emailList);
});
io.on('connection', webSocketConnection(mailserver));
});
port = port || 1080;
host = host || '0.0.0.0';
// Get single email
app.get('/email/:id', function(req, res){
server.listen(port, host);
mailserver.getEmail( req.params.id, function(err, email){
if (err) return res.status(404).json({ error: err.message });
logger.info('MailDev app running at %s:%s', host, port);
// Mark the email as 'read'
email.read = true;
res.json(email);
});
});
// Delete all emails
app.delete('/email/all', function(req, res){
mailserver.deleteAllEmail(function(err){
if (err) return res.status(500).json({ error: err.message });
res.json(true);
});
});
// Delete email by id
app.delete('/email/:id', function(req, res){
mailserver.deleteEmail(req.params.id, function(err){
if (err) return res.status(500).json({ error: err.message });
res.json(true);
});
});
// Get Email HTML
app.get('/email/:id/html', function(req, res){
mailserver.getEmail( req.params.id, function(err, email){
if (err) return res.status(404).json({ error: err.message });
res.send(email.html);
});
});
// Serve Attachments
app.get('/email/:id/attachment/:filename', function(req, res){
mailserver.getEmailAttachment(req.params.id, req.params.filename, function(err, contentType, readStream){
if (err) return res.status(404).json('File not found');
res.contentType(contentType);
readStream.pipe(res);
});
});
// Serve email.eml
app.get('/email/:id/download', function(req, res){
mailserver.getEmailEml(req.params.id, function(err, contentType, filename, readStream){
if (err) return res.status(404).json('File not found');
res.setHeader('Content-disposition', 'attachment; filename=' + filename);
res.contentType(contentType);
readStream.pipe(res);
});
});
// Get email source from .eml file
app.get('/email/:id/source', function(req, res){
mailserver.getRawEmail( req.params.id, function(err, readStream){
if (err) return res.status(404).json('File not found');
readStream.pipe(res);
});
});
// Get any config settings for display
app.get('/config', function(req, res){
res.json({
version: pkg.version
, smtpPort: mailserver.port
, outgoingHost: mailserver.outgoingHost
});
});
// Relay the email
app.post('/email/:id/relay', function(req, res){
mailserver.getEmail(req.params.id, function(err, email){
if (err) return res.status(404).json({ error: err.message });
mailserver.relayMail(email, function(err) {
if (err) return res.status(500).json({ error: err.message });
res.json(true);
});
});
});
/**
* Socket.io
*/
function emitNewMail(socket){
return function(email){
socket.emit('newMail', email);
};
}
io.on('connection', function(socket){
// When a new email arrives, the 'new' event will be emitted
mailserver.on('new', emitNewMail(socket));
socket.on('disconnect', function(){
mailserver.removeListener('new', emitNewMail(socket));
});
});
};
{
"name": "maildev",
"description": "SMTP Server and Web Interface for reading and testing emails during development",
"version": "0.9.1",
"version": "0.10.0",
"keywords": [

@@ -34,23 +34,28 @@ "email",

"dependencies": {
"commander": "~2.1.0",
"express": "~4.9.5",
"commander": "~2.8.0",
"express": "^4.12.3",
"mailcomposer": "~0.2.11",
"mailparser": "~0.3.6",
"mailparser": "^0.5.0",
"open": "~0.0.5",
"simplesmtp": "~0.3.32",
"socket.io": "~1.1.0"
"simplesmtp": "^0.3.35",
"socket.io": "^1.3.5"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-concurrent": "~0.4.2",
"grunt-contrib-jshint": "^0.9.2",
"grunt-concurrent": "^1.0.0",
"grunt-contrib-jshint": "^0.11.2",
"grunt-contrib-watch": "^0.6.1",
"grunt-nodemon": "~0.1.2",
"grunt-sass": "~0.9.0",
"matchdep": "~0.1.1",
"nodemailer": "~1.3.0"
"grunt-nodemon": "^0.4.0",
"grunt-sass": "^0.18.1",
"matchdep": "^0.3.0",
"mocha": "^2.2.5",
"nodemailer": "^1.3.4",
"smtp-connection": "^1.2.0"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "./node_modules/mocha/bin/mocha"
}
}
# MailDev
[![NPM version](https://badge.fury.io/js/maildev.png)](http://badge.fury.io/js/maildev)
[![Build Status](https://api.travis-ci.org/djfarrelly/MailDev.svg)](https://travis-ci.org/djfarrelly/MailDev)
[![NPM Version](https://img.shields.io/npm/v/maildev.svg)](https://www.npmjs.com/package/maildev)

@@ -16,2 +17,4 @@ **MailDev** is a simple way to test your project's generated emails during development with an easy to use web interface that runs on your machine built on top of [Node.js](http://www.nodejs.org).

For convenient use with Grunt, try [grunt-maildev](https://github.com/xavierpriour/grunt-maildev).
## Usage

@@ -23,4 +26,5 @@

-V, --version output the version number
-s, --smtp [port] SMTP port to catch emails [1025]
-w, --web [port] Port to run the Web GUI [1080]
-s, --smtp <port> SMTP port to catch emails [1025]
-w, --web <port> Port to run the Web GUI [1080]
--ip <ip address> IP Address to bind services to [0.0.0.0]
--outgoing-host <host> SMTP host for outgoing emails

@@ -31,2 +35,6 @@ --outgoing-port <port> SMTP port for outgoing emails

--outgoing-secure Use SMTP SSL for outgoing emails
--incoming-user <user> SMTP user for incoming emails
--incoming-pass <pass> SMTP password for incoming emails
--web-user <user> HTTP basic auth username
--web-pass <pass> HTTP basic auth password
-o, --open Open the Web GUI after startup

@@ -126,39 +134,8 @@ -v, --verbose

To run the test suite, use [Mocha](http://visionmedia.github.io/mocha/):
To run the test suite:
$ npm install -g mocha
$ mocha
$ npm run test
## Changelog
## [Changelog](https://github.com/djfarrelly/MailDev/releases)
0.9.1 - Display unread count in the title
0.9.0 - Add ability to download `.eml` files
0.8.1 - Fix temp directory bug introduced in 0.8.0
0.8.0 - Add view email source. Fix running multiple instances.
0.7.0 - Add Docker support
0.6.3 - Add auto-show new email. UI adjustments.
0.6.2 - Fix module entry point. Bug fixes.
0.6.1 - Bug fixes and improvements
0.6.0 - Add relay option to send outgoing emails. Refactor for new API.
0.5.2 - Lock down dependency versions
0.5.1 - Fix menu layout issue in Safari
0.5.0 - Add command line interface. Web UI redesign.
0.4.0 - Add ability to receive and view attachments
0.3.1 - Add Socket.io for immediate email arrival to interface
0.3.0 - Initial open source release
## Thanks

@@ -165,0 +142,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc