Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@keyro/keyro-emails-send

KeyroLearning58UNLICENSED1.4.3TypeScript support: included

Send an email through Keyro Emails

readme

README

Quickly send mail through KeyroEmail.

ZERO CONF

You don't need to do heck. For prod, force process.env.PROD to true.

If you want to configure anyway, you can force replace all config using the following environment variables:

  • KEYRO_EMAIL_TOPIC_ARN: KeyroEmail sens-email topic ARN
  • KEYRO_EMAIL_TOPIC_REGION: KeyroEmail sens-email topic region
  • KEYRO_EMAIL_FROM: Email address used in the 'from' email field

USAGE

  1. Declare an email `js // src/emails/templates/greetings.ts import { sendEmail } from '@keyro/keyro-emails-send'

// Without data parameters export const sendAnonymousGreetings = sendEmail<undefined>({ genSubject() { return Hello dude }, genTemplate() { return <mjml> <mj-body width="600px"> <mj-text> Hello dude. We are happy to see you ! </mj-text> </mj-body> </mjml> } })

// With data parameters export const sendGreetings = sendEmail<{ firstname: string }>({ genSubject({ firstname }) { return Hello ${firstname} }, genTemplate({ firstname }) { return <mjml> <mj-body width="600px"> <mj-text> Hello ${firstname}. We are happy to see you ! </mj-text> </mj-body> </mjml> } })


2. Send it

```js
// src/emails/foobar.ts
import { sendAnonymousGreetings, sendGreetings } from './templates/greetings'

const contact = await fetchContactByEmail('sslimani@keyro.fr')
const firstname = contact.firstname

// send to one recipient
await sendAnonymousGreetings('sslimani@keyro.fr')

// send with data some aditional data that can be inserted
await sendGreetings('sslimani@keyro.fr', { firstname })

// send with options (like attachments)
await sendGreetings('sslimani@keyro.fr', { firstname }, {
  cc: 'boss@keyro.fr',
  attachments: [{
    file_name: 'kerbal-space-program.gif',
    url: 'https://whatever.gif'
  }]
})

// send to multiple recipients
await sendAnonymousGreetings([
  'vrebiardcrepin@keyro.fr',
  'nboutte@keyro.fr',
  'sslimani@keyro.fr'
])