diff options
| author | Adam Soltys <[email protected]> | 2022-09-02 14:47:08 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-09-02 14:47:14 -0700 |
| commit | 3161dd7ee95b6c7d70f8341298dd4fab84cda8b0 (patch) | |
| tree | 16cd6c55d5dc481331b1e8b640d179f193e7ea13 /lib/mail.js | |
| parent | 7a8d64833de8873afb92982b3f5bfff59b30c542 (diff) | |
| download | coinos-server-3161dd7ee95b6c7d70f8341298dd4fab84cda8b0.tar.gz coinos-server-3161dd7ee95b6c7d70f8341298dd4fab84cda8b0.zip | |
es6 migration
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() { |
