Prompt

How do I send emails programmatically?

Technology / Api platforms2 observationsLast seen Oct 27, 2026

Latest observation

Oct 27, 2026OpenAI APIWeb search: off

You generally send emails programmatically in one of two ways:

  1. Use an email-sending API/service
    Examples: SendGrid, Mailgun, Amazon SES, Postmark, Mailtrap (testing).
    This is usually the easiest and most reliable option for production.

  2. Use SMTP directly
    Your app connects to an SMTP server (like Gmail, Outlook, or your own mail server) and sends the message.

Typical steps

  1. Create an email account or choose an email service.
  2. Get credentials/API keys.
  3. Build the email content:
    • recipient
    • subject
    • body (plain text or HTML)
  4. Send it from your code.
  5. Handle errors, retries, and logging.

Example: Python with SMTP

import smtplib
from email.mime.text import MIMEText

sender = "you@example.com"
password = "your_password_or_app_password"
recipient = "someone@example.com"

msg = MIMEText("Hello from Python!")
msg["Subject"] = "Test Email"
msg["From"] = sender
msg["To"] = recipient

with smtplib.SMTP_SSL("smtp.gmail.com", 465) as server:
    server.login(sender, password)
    server.sendmail(sender, [recipient], msg.as_string())

Example: Node.js with Nodemailer

const nodemailer = require("nodemailer");

async function sendEmail() {
  let transporter = nodemailer.createTransport({
    host: "smtp.gmail.com",
    port: 465,
    secure: true,
    auth: {
      user: "you@example.com",
      pass: "your_password_or_app_password",
    },
  });

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

sendEmail().catch(console.error);

Important notes

  • Use app passwords or API keys, not your normal password when possible.
  • For production email, pay attention to:
    • SPF, DKIM, DMARC
    • spam filtering
    • rate limits
    • bounce handling
  • If you only want to test, use a sandbox like Mailtrap.

If you want, I can show you how to do this in Python, JavaScript, Java, C#, PHP, or Go.

Observation history

How did Obsurfable measure this prompt?

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