diff options
| author | Adam Soltys <[email protected]> | 2022-06-22 21:00:44 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-06-22 21:00:44 -0700 |
| commit | d277cd3e95c1e2c53f49ac965051e77319a0d8d5 (patch) | |
| tree | 0644274c53c1c712ae1d1758344aaebcf1644680 /index.js | |
| parent | 268d283d830d8cb8f35415f2f168bae69c8a9b6e (diff) | |
| download | coinos-server-d277cd3e95c1e2c53f49ac965051e77319a0d8d5.tar.gz coinos-server-d277cd3e95c1e2c53f49ac965051e77319a0d8d5.zip | |
update email endpoint
Diffstat (limited to 'index.js')
| -rw-r--r-- | index.js | 35 |
1 files changed, 18 insertions, 17 deletions
@@ -108,30 +108,31 @@ app.post("/email", async (req, res) => { try { let file = persist("data/emails.json"); file.emails = [...file.emails, req.body]; - res.send({ ok: true }); try { - // Require: - var postmark = require("postmark"); + // Require: + var postmark = require("postmark"); - // Send an email: - var client = new postmark.ServerClient( - config.postmark - ); + // Send an email: + var client = new postmark.ServerClient(config.postmark); - client.sendEmail({ - From: "[email protected]", - To: "[email protected]", - Subject: "Email Signup", - HtmlBody: JSON.stringify(req.body), - TextBody: JSON.stringify(req.body), - MessageStream: "outbound" - }); - } catch(e) { + await client.sendEmail({ + From: "[email protected]", + To: "[email protected]", + Subject: req.body.subject || "Email Signup", + HtmlBody: JSON.stringify(req.body), + TextBody: JSON.stringify(req.body), + MessageStream: "outbound" + }); + + res.send({ ok: true }); + } catch (e) { console.log("problem sending email", e); - } + res.code(500).send(e.message); + } } catch (e) { console.log(e); + res.code(500).send(e.message); } }); |
