import Mailjet from 'node-mailjet'

const mailjet = Mailjet.apiConnect(
  process.env.MJ_API_KEY || '',
  process.env.MJ_SECRET_KEY || ''
)

export async function sendMailjetEmail({ to, subject, text }: {
  to: string,
  subject: string,
  text: string
}) {
  await mailjet.post('send', { version: 'v3.1' }).request({
    Messages: [{
      From: {
          Email: 'dev@twotalesdev.com',
          Name: 'TransferTribe'
        },
      To: [{ Email: to }],
      Subject: subject,
      TextPart: text
    }]
  })
}
