diff --git a/keyserver/src/emails/sendmail.js b/keyserver/src/emails/sendmail.js --- a/keyserver/src/emails/sendmail.js +++ b/keyserver/src/emails/sendmail.js @@ -1,7 +1,10 @@ // @flow +import invariant from 'invariant'; import nodemailer from 'nodemailer'; +import { importJSON } from '../utils/import-json.js'; + type MailInfo = { +from: string, +to: string, @@ -14,6 +17,26 @@ ... }; -const sendmail: Transport = nodemailer.createTransport({ sendmail: true }); +type PostmarkConfig = { + +apiToken: string, +}; + +async function getSendmail(): Promise { + const postmark: ?PostmarkConfig = await importJSON({ + folder: 'facts', + name: 'postmark', + }); + invariant(postmark, 'Postmark config missing'); + return nodemailer.createTransport({ + host: 'smtp.postmarkapp.com', + port: 587, + secure: false, + auth: { + user: postmark.apiToken, + pass: postmark.apiToken, + }, + requireTLS: true, + }); +} -export default sendmail; +export default getSendmail; diff --git a/keyserver/src/emails/subscribe-email-updates.js b/keyserver/src/emails/subscribe-email-updates.js --- a/keyserver/src/emails/subscribe-email-updates.js +++ b/keyserver/src/emails/subscribe-email-updates.js @@ -6,7 +6,7 @@ import ashoat from 'lib/facts/ashoat'; import type { EmailSubscriptionRequest } from 'lib/types/account-types'; -import sendmail from './sendmail'; +import getSendmail from './sendmail'; import Template from './template.react'; async function sendEmailSubscriptionRequestToAshoat( @@ -22,8 +22,9 @@ ); const html = renderEmail(email); + const sendmail = await getSendmail(); await sendmail.sendMail({ - from: 'no-reply@squadcal.org', + from: 'no-reply@comm.app', to: ashoat.landing_email, subject: title, html,