forked from maildev/maildev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
67 lines (57 loc) · 1.79 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* MailDev - index.js
*
* Author: Dan Farrelly <[email protected]>
* Licensed under the MIT License.
*/
var program = require('commander')
, pkg = require('./package.json')
, web = require('./lib/web')
, mailserver = require('./lib/mailserver')
, logger = require('./lib/logger')
;
module.exports = function(config) {
var version = pkg.version;
if (!config) {
// CLI
config = program
.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('--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-secure', 'Use SMTP SSL for outgoing emails')
.option('-o, --open', 'Open the Web GUI after startup')
.option('-v, --verbose')
.parse(process.argv);
}
if (config.verbose){
logger.init(true);
}
// Start the Mailserver & Web GUI
mailserver.listen( config.smtp );
if (
config.outgoingHost ||
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);
if (config.open){
var open = require('open');
open('http://localhost:' + config.web);
}
return mailserver;
};