2022-01-02 00:08:52 +00:00
|
|
|
import * as mailgun from 'mailgun-js'
|
|
|
|
import * as functions from 'firebase-functions'
|
|
|
|
|
2022-01-07 00:33:19 +00:00
|
|
|
const DOMAIN = 'mg.manifold.markets'
|
2022-01-02 00:08:52 +00:00
|
|
|
const mg = mailgun({ apiKey: functions.config().mailgun.key, domain: DOMAIN })
|
|
|
|
|
|
|
|
export const sendEmail = (to: string, subject: string, text: string) => {
|
|
|
|
const data = {
|
2022-01-07 00:33:19 +00:00
|
|
|
from: 'Manifold Markets <no-reply@manifold.markets>',
|
2022-01-02 00:08:52 +00:00
|
|
|
to,
|
|
|
|
subject,
|
|
|
|
text,
|
|
|
|
}
|
|
|
|
|
|
|
|
return mg.messages().send(data, (error, body) => {
|
|
|
|
console.log('Sent email', error, body)
|
|
|
|
})
|
|
|
|
}
|