Prompt

How to send email from Express

Technology / Api platforms5 observationsLast seen Sep 23, 2026

Latest observation

Sep 23, 2026CopilotWeb search: on

You can send email from an Express.js app using libraries like Nodemailer (SMTP-based) or modern email APIs (SendLayer, Resend, Postmark). The simplest approach is to set up a route in Express that calls Nodemailer with your credentials, or use an API provider for better deliverability and security.

🔧 Using Nodemailer (SMTP)

Install dependencies

bash

npm install express nodemailer body-parser dotenv

Configure transporter

js

const nodemailer = require("nodemailer");

const transporter = nodemailer.createTransport({

  • service: "gmail", // or outlook, yahoo, etc.
  • auth: {
  • user: process.env.EMAIL_USER,
  • pass: process.env.EMAIL_PASS

}

});

Create route in Express

js

app.post("/send-email", async (req, res) => {

const { to, subject, text } = req.body;

try {

  • await transporter.sendMail({ from: process.env.EMAIL_USER, to, subject, text });

res.send("Email sent successfully!");

} catch (err) {

res.status(500).send("Error sending email");

}

});

🌐 Using Email APIs (No SMTP)

If you don’t want to deal with SMTP, use an API provider:

SendLayer / Resend / Postmark / SendGrid

Sign up and get an API key.

Verify your domain (SPF/DKIM setup).

Use fetch or axios in your Express route to call their HTTPS endpoint.

js

const axios = require("axios");

app.post("/send-email", async (req, res) => {

const { to, subject, text } = req.body;

try {

await axios.post("https://api.resend.com/emails", {

to,

subject,

text

}, {

  • headers: { Authorization: Bearer ${process.env.RESEND_API_KEY} }

});

res.send("Email sent via API!");

} catch (err) {

res.status(500).send("Error sending email");

}

});

⚠️ Best Practices

Use environment variables (.env) for credentials.

Never expose API keys in client-side code.

Set up SPF/DKIM/DMARC for your domain to avoid spam folders.

Log and monitor delivery status with webhooks or dashboards.

✅ When to Choose What

  • Quick setup, small apps: Nodemailer with Gmail/Outlook.

  • Scalable, production-ready apps: API providers like Resend, Postmark, or SendGrid.

  • Cost-sensitive, high-volume apps: Amazon SES (requires more setup).

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (5 observations 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.