Skip to content

Use NUXT_POSTMARK_FROM and NUXT_POSTMARK_BCC Instead of Plain Text in sendWelcomeEmail Function #21

@antoinekm

Description

@antoinekm

Hi @harlan-zw,
While attempting to send emails, I encountered the following error:

image
422 - An error occurred
While your account is pending approval, all recipient addresses must share the same domain as the 'From' address. The domain of the 'From' address is 'harlanzw.com', but you are attempting to send email to the following domain(s): 'tonightpass.com'.

To resolve this and improve flexibility, we should replace the hardcoded From and Bcc email addresses in the sendWelcomeEmail function with configurable environment variables (NUXT_POSTMARK_FROM and NUXT_POSTMARK_BCC).

Current Function:

export function sendWelcomeEmail(event: H3Event, email: string) {
  const client = new ServerClient(useRuntimeConfig(event).postmark.apiKey)
  return client.sendEmail({
    From: 'harlan@harlanzw.com',
    Bcc: 'harlan@harlanzw.com',
    To: email,
    Subject: 'Welcome to Request Indexing',
    TextBody: WelcomeEmail,
  })
}

Proposed Changes:
Replace 'harlan@harlanzw.com' in the From and Bcc fields with environment variables NUXT_POSTMARK_FROM and NUXT_POSTMARK_BCC, respectively.

Tasks:

  1. Update the sendWelcomeEmail function to retrieve From and Bcc addresses from environment variables.
  2. Add NUXT_POSTMARK_FROM and NUXT_POSTMARK_BCC to .env.example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions