Prompt

How do I send emails from a Node app?

Technology / Api platforms1 observationLast seen Sep 23, 2026

Latest observation

Sep 23, 2026OpenAI APIWeb search: off

The usual way is to use SMTP with a library like Nodemailer.

1) Install Nodemailer

npm install nodemailer

2) Create a transporter

Example using Gmail SMTP or any SMTP provider:

const nodemailer = require("nodemailer");

const transporter = nodemailer.createTransport({
  host: "smtp.example.com",
  port: 587,
  secure: false, // true for 465, false for 587
  auth: {
    user: "your-email@example.com",
    pass: "your-email-password-or-app-password",
  },
});

3) Send an email

async function sendEmail() {
  try {
    const info = await transporter.sendMail({
      from: '"My App" <your-email@example.com>',
      to: "recipient@example.com",
      subject: "Hello from Node",
      text: "This is a plain text email.",
      html: "<p>This is an <b>HTML</b> email.</p>",
    });

    console.log("Message sent:", info.messageId);
  } catch (err) {
    console.error("Error sending email:", err);
  }
}

sendEmail();

4) Use environment variables

Don’t hardcode credentials:

EMAIL_USER=your-email@example.com
EMAIL_PASS=your-password
SMTP_HOST=smtp.example.com
SMTP_PORT=587

Then:

require("dotenv").config();
const nodemailer = require("nodemailer");

const transporter = nodemailer.createTransport({
  host: process.env.SMTP_HOST,
  port: Number(process.env.SMTP_PORT),
  secure: false,
  auth: {
    user: process.env.EMAIL_USER,
    pass: process.env.EMAIL_PASS,
  },
});

Notes

  • For Gmail, you usually need an App Password if 2FA is enabled.
  • For production, consider services like SendGrid, Mailgun, Amazon SES, or Postmark for better deliverability.
  • If you need to send lots of emails, use a queue/background job so requests don’t block.

If you want, I can give you:

  1. a Gmail-specific example,
  2. a SendGrid example, or
  3. a full Express API endpoint for sending mail.

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.