A service for sending html or transactional emails powered by Sendgrid. It is setup to disable as much of Sendgrid's tracking as possible.

const env: { SENDGRID_API_KEY: string }
const mailConfig: {
replyToEmail: string,
fromEmail: string,
}

const email = new EmailService({ env, mailConfig })

Hierarchy

  • EmailService

Constructors

Methods

Constructors

Methods

  • sendEmail dispatches an HTML-based email to be sent to an specific email address.

    await email.sendEmail(
    'geoff@example.com',
    'Hi Geoff!',
    `<p> Welcome to your new account! </p>`
    )

    Parameters

    • to: string
    • subject: string
    • html: string

    Returns Promise<void>

  • sendTransactional dispatches a transaction email, i.e. the template is setup on app.sendgrid.com to be sent to a specific email address

    await email.sendTransactional(
    'geoff@example.com',
    'Hi Geoff!',
    'd-abcdefghijklmnop',
    {
    firstName: 'Geoff',
    body: 'Welcome to your new account!',
    action: 'Log in',
    href: 'https://example.com/login',
    }
    )

    Parameters

    • to: string
    • subject: string
    • templateId: string
    • data: Record<string, unknown>

    Returns Promise<void>

Generated using TypeDoc