Sending Emails with AutoSend
Browse the source code here.
LaunchFa.st makes it easier for you to send emails with AutoSend with it’s built-in integration.
Here’s how you would set up AutoSend to use it with LaunchFast:
-
Create a AutoSend account.
-
Link your domain by completing the steps in their domain guide.
-
Obtain the AutoSend API key from https://autosend.com/settings/api-key.
-
Make sure to update the environment variable(s) of your application per the following instruction:
To send emails with AutoSend, use sendEmail utility inside your server-side code:
import { sendEmail } from '@/lib/utils/email'import type { APIContext } from 'astro'
export async function GET({ request }: APIContext) { // From a server-side API that is being fetched
// Send an email using AutoSend // Read more on https://docs.autosend.com/quickstart/email-using-api await sendEmail({ text: context.text, subject: context.subject, from: 'Rishi Raj Jain <emails@rishi.app>', to: typeof context.to === 'string' ? [context.to] : context.to, }, 'autosend')}
export async function POST({ request }: APIContext) { // From a server-side API that is being POST-ed to
// Send an email using AutoSend // Read more on https://docs.autosend.com/quickstart/email-using-api await sendEmail({ text: context.text, subject: context.subject, from: 'Rishi Raj Jain <emails@rishi.app>', to: typeof context.to === 'string' ? [context.to] : context.to, }, 'autosend')}