Prompt

How do I send email from a serverless app?

Technology / API Platforms1 observationLast seen Nov 13, 2026

Latest observation

Nov 13, 2026OpenAI APIWeb search: off

To send email from a serverless app, the usual approach is:

  1. Use a third-party email service
    Examples: SendGrid, Mailgun, Amazon SES, Postmark, Resend, etc.

  2. Call that service from a serverless function
    Your app (e.g. AWS Lambda, Vercel Functions, Azure Functions, Cloudflare Workers) invokes the email API when needed.

  3. Keep credentials in environment variables / secrets
    Never hardcode API keys in client-side code.

Common pattern

  • User submits a form
  • Your frontend sends the data to a serverless endpoint
  • The function validates input
  • The function sends the email through an email provider API
  • Return success/failure to the frontend

Example using Node.js + SendGrid

import sgMail from '@sendgrid/mail';

sgMail.setApiKey(process.env.SENDGRID_API_KEY);

export default async function handler(req, res) {
  if (req.method !== 'POST') {
    return res.status(405).json({ error: 'Method not allowed' });
  }

  const { name, email, message } = req.body;

  try {
    await sgMail.send({
      to: 'you@example.com',
      from: 'verified-sender@yourdomain.com',
      subject: `New message from ${name}`,
      text: `From: ${email}\n\n${message}`,
    });

    return res.status(200).json({ ok: true });
  } catch (err) {
    console.error(err);
    return res.status(500).json({ error: 'Failed to send email' });
  }
}

Things to watch out for

  • Domain verification: Most services require you to verify your sender domain.
  • Spam prevention: Add CAPTCHA, rate limiting, and input validation.
  • Cold starts / timeouts: Keep the function simple and fast.
  • Deliverability: Set up SPF, DKIM, and DMARC for your domain.
  • Never send directly from the browser: That exposes your email API key.

If you want the simplest setup

Use a provider with a straightforward API:

  • Resend: very simple for modern apps
  • Postmark: great deliverability
  • SendGrid: popular, lots of features
  • Amazon SES: cheaper at scale, more setup

If you tell me your serverless platform (AWS Lambda, Vercel, Netlify, Cloudflare Workers, etc.) and your language, I can give you a ready-to-use example.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.