* Create 500-mana.html * Update 500-mana.html Fixed typos and links not working * Added "create a good market" guide added page creating-market.html For Stephen to set up condition (email 3 days after signing up) * Update 500-mana.html updated 500 Mana email (still need to make changes to create market guide) * email changes * sendOneWeekBonusEmail logic * add dayjs as dependency * don't use mailgun scheduling Co-authored-by: mantikoros <sgrugett@gmail.com>
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import * as mailgun from 'mailgun-js'
|
|
|
|
const initMailgun = () => {
|
|
const apiKey = process.env.MAILGUN_KEY as string
|
|
return mailgun({ apiKey, domain: 'mg.manifold.markets' })
|
|
}
|
|
|
|
export const sendTextEmail = (to: string, subject: string, text: string) => {
|
|
const data: mailgun.messages.SendData = {
|
|
from: 'Manifold Markets <info@manifold.markets>',
|
|
to,
|
|
subject,
|
|
text,
|
|
// Don't rewrite urls in plaintext emails
|
|
'o:tracking-clicks': 'htmlonly',
|
|
}
|
|
const mg = initMailgun()
|
|
return mg.messages().send(data, (error) => {
|
|
if (error) console.log('Error sending email', error)
|
|
else console.log('Sent text email', to, subject)
|
|
})
|
|
}
|
|
|
|
export const sendTemplateEmail = (
|
|
to: string,
|
|
subject: string,
|
|
templateId: string,
|
|
templateData: Record<string, string>,
|
|
options?: Partial<mailgun.messages.SendTemplateData>
|
|
) => {
|
|
const data: mailgun.messages.SendTemplateData = {
|
|
...options,
|
|
from: options?.from ?? 'Manifold Markets <info@manifold.markets>',
|
|
to,
|
|
subject,
|
|
template: templateId,
|
|
'h:X-Mailgun-Variables': JSON.stringify(templateData),
|
|
}
|
|
const mg = initMailgun()
|
|
|
|
return mg.messages().send(data, (error) => {
|
|
if (error) console.log('Error sending email', error)
|
|
else console.log('Sent template email', templateId, to, subject)
|
|
})
|
|
}
|