Namby Pamby Magicians

    @keyro/keyro-emails-send
    TypeScript icon, indicating that this package has built-in type declarations

    1.3.2 • Public • Published

    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
    // 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>
        `
      }
    })
    1. Send it
    // 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'
    ])

    Keywords

    none

    Install

    npm i @keyro/keyro-emails-send

    DownloadsWeekly Downloads

    3

    Version

    1.3.2

    License

    UNLICENSED

    Unpacked Size

    23 kB

    Total Files

    27

    Last publish

    Collaborators

    • bluer4v3n
    • 7hanith
    • vblitz