diff options
Diffstat (limited to 'lib/mail.js')
| -rw-r--r-- | lib/mail.js | 62 |
1 files changed, 29 insertions, 33 deletions
diff --git a/lib/mail.js b/lib/mail.js index b8242f9c..9d2ff7fc 100644 --- a/lib/mail.js +++ b/lib/mail.js @@ -1,7 +1,9 @@ -import fs from 'fs'; -import Imap from 'imap'; -import { inspect } from 'util'; -import persist from './persist'; +import app from "../app.js"; +import config from "../config/index.js"; +import fs from "fs"; +import Imap from "imap"; +import { inspect } from "util"; +import persist from "./persist.js"; const emails = persist("data/emails.json"); let imap = new Imap(config.imap); @@ -9,37 +11,31 @@ function openInbox(cb) { imap.openBox("INBOX", true, cb); } -app.post( - "/contact-sil", - ah((req, res) => { - const mailgun = require("mailgun-js")(config.mailgun); - let data = { - subject: "Contact form", - text: JSON.stringify(req.body), - from: "[email protected]", - to: "[email protected]" - }; +app.post("/contact-sil", (req, res) => { + const mailgun = require("mailgun-js")(config.mailgun); + let data = { + subject: "Contact form", + text: JSON.stringify(req.body), + from: "[email protected]", + to: "[email protected]" + }; - mailgun.messages().send(data); - res.send(req.body); - }) -); + mailgun.messages().send(data); + res.send(req.body); +}); -app.post( - "/contact", - ah((req, res) => { - const mailgun = require("mailgun-js")(config.mailgun); - let data = { - subject: "Contact form", - text: JSON.stringify(req.body), - from: "[email protected]", - to: "[email protected]" - }; +app.post("/contact", (req, res) => { + const mailgun = require("mailgun-js")(config.mailgun); + let data = { + subject: "Contact form", + text: JSON.stringify(req.body), + from: "[email protected]", + to: "[email protected]" + }; - mailgun.messages().send(data); - res.send(req.body); - }) -); + mailgun.messages().send(data); + res.send(req.body); +}); imap.once("ready", function() { openInbox(function(err, box) { @@ -55,7 +51,7 @@ imap.once("ready", function() { msg.on("body", function(stream, info) { let buffer = ""; stream.on("data", function(chunk) { - //stream.pipe(fs.createWriteStream('msg-' + seqno + '-body.txt', {flags:'a+'})); + //stream.pipe(fs.createWriteStream('msg-' + seqno + '-body.txt', {flags:'a+'}); buffer += chunk.toString("utf8"); }); stream.once("end", async function() { |
