send HTTP headers with -H option
This commit is contained in:
parent
7e583eb22c
commit
13c876a2dc
@ -5,8 +5,9 @@ Usage
|
||||
-----
|
||||
```sh
|
||||
Usage: smtp2http [-v|--verbose] [-s|--silent|-q|--quiet]
|
||||
[-T|--tls=<tls_opt>] ENDPOINT
|
||||
[-T|--tls=<tls_opt>] [[-H|--header=<header>], ...] ENDPOINT
|
||||
|
||||
-H --header=<header> HTTP header to send with requests
|
||||
-q --quiet Do not log to STDERR
|
||||
-s --silent Alias for --quiet
|
||||
-T --tls=<tls_opt> colon-delimited list of cert files
|
||||
@ -89,4 +90,4 @@ openssl pkcs12 -export \
|
||||
-out example.com.pfx \
|
||||
-in example.com.crt -inkey example.com.key \
|
||||
-certfile example.com-ca.crt
|
||||
```
|
||||
```
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "smtp2http",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"description": "SMTP to HTTP gateway",
|
||||
"bin": {
|
||||
"smtp2http": "./smtp2http.js"
|
||||
|
||||
12
smtp2http.js
12
smtp2http.js
@ -14,11 +14,18 @@ squabble.shortOpts().longOpts().stopper()
|
||||
.option("-T", "--tls")
|
||||
.flag("-s", "-q", "--silent", "--quiet")
|
||||
.flag("-v", "--verbose")
|
||||
.list("-H", "--header")
|
||||
.required("ENDPOINT");
|
||||
|
||||
// parse arguments
|
||||
// parse and apply arguments
|
||||
args = squabble.parse();
|
||||
serverOpts.endpoint = args.named.ENDPOINT;
|
||||
serverOpts.headers = {};
|
||||
args.named["--header"].forEach(function(headerLine) {
|
||||
var name = headerLine.split(":")[0];
|
||||
serverOpts.headers[name] = serverOpts.headers[name] || [];
|
||||
serverOpts.headers[name].push(headerLine.substr(name.length+1).trim());
|
||||
});
|
||||
|
||||
// configure console output
|
||||
if (args.named["--quiet"]) {
|
||||
@ -64,7 +71,8 @@ smtp.createServer(serverOpts, function(req) {
|
||||
stream.pipe(new MailParser().on("end", function(email) {
|
||||
http.post({
|
||||
url: serverOpts.endpoint,
|
||||
json: email
|
||||
json: email,
|
||||
headers: serverOpts.headers
|
||||
}, function(err, res, body) {
|
||||
var msg;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user