Prompt

How do I send emails programmatically?

Technology / Api platforms1 observationLast seen Sep 23, 2026

Latest observation

Sep 23, 2026OpenAI APIWeb search: off

You usually send emails programmatically in one of these ways:

1) Use an email-sending service or SMTP server

Common options:

  • SMTP with providers like Gmail, Outlook, your company mail server
  • Transactional email APIs like SendGrid, Mailgun, Amazon SES, Postmark

2) Basic SMTP flow

At a high level:

  1. Connect to the SMTP server
  2. Authenticate
  3. Set sender, recipient(s), subject, and body
  4. Send the message

3) Example in Python using SMTP

import smtplib
from email.message import EmailMessage

msg = EmailMessage()
msg["Subject"] = "Test Email"
msg["From"] = "you@example.com"
msg["To"] = "recipient@example.com"
msg.set_content("Hello from Python!")

with smtplib.SMTP("smtp.example.com", 587) as smtp:
    smtp.starttls()
    smtp.login("you@example.com", "your_password")
    smtp.send_message(msg)

4) Example in Node.js using Nodemailer

const nodemailer = require("nodemailer");

async function main() {
  let transporter = nodemailer.createTransport({
    host: "smtp.example.com",
    port: 587,
    secure: false,
    auth: {
      user: "you@example.com",
      pass: "your_password"
    }
  });

  await transporter.sendMail({
    from: "you@example.com",
    to: "recipient@example.com",
    subject: "Test Email",
    text: "Hello from Node.js!"
  });
}

main().catch(console.error);

5) Best practices

  • Use app passwords or OAuth when available instead of your main password
  • Prefer TLS/STARTTLS
  • For production, use a transactional email service
  • Handle bounce/errors and rate limits
  • Don’t send spam; make sure recipients opted in

6) If you want a quick recommendation

  • Small scripts / testing: SMTP
  • Production apps: SendGrid / Mailgun / SES / Postmark

If you tell me your language (Python, JavaScript, Java, etc.) and which email provider you want to use, I can give you a working 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.