Prompt

How do I send an email when a user changes their address?

Technology / Api platforms1 observationLast seen Sep 23, 2026

Latest observation

Sep 23, 2026OpenAI APIWeb search: off

You can do this by detecting the address change in your backend and then triggering an email notification.

Common approach

1. Compare old vs. new address

When the user submits an update, check whether the address fields changed:

  • street
  • city
  • state/province
  • postal code
  • country

If any of those changed, trigger an email.

2. Save the updated address

Update the user record in your database first, or in the same transaction if possible.

3. Send the email

Use an email service like:

  • SendGrid
  • Amazon SES
  • Mailgun
  • Postmark
  • Nodemailer with SMTP

Example logic

Pseudocode

if (oldAddress !== newAddress) {
  saveNewAddress();
  sendEmail(user.email, "Your address was updated", "We noticed your address changed.");
}

Example in Node.js

const nodemailer = require("nodemailer");

async function updateAddress(userId, newAddress) {
  const user = await db.users.findById(userId);
  const oldAddress = user.address;

  const addressChanged =
    oldAddress.street !== newAddress.street ||
    oldAddress.city !== newAddress.city ||
    oldAddress.state !== newAddress.state ||
    oldAddress.zip !== newAddress.zip ||
    oldAddress.country !== newAddress.country;

  if (addressChanged) {
    await db.users.update(userId, { address: newAddress });

    const transporter = nodemailer.createTransport({
      host: "smtp.example.com",
      port: 587,
      auth: {
        user: "smtp-user",
        pass: "smtp-pass",
      },
    });

    await transporter.sendMail({
      from: "no-reply@yourapp.com",
      to: user.email,
      subject: "Your address has been updated",
      text: "We noticed your address was changed in your account.",
    });
  }
}

Better practice

If you want this to happen reliably:

  • use a database trigger or application event
  • send the email asynchronously via a background job queue
  • log the change for audit purposes
  • avoid sending duplicate emails if the user updates the same address twice quickly

If you want, I can also show you:

  • a version for Python/Django
  • PHP/Laravel
  • Ruby on Rails
  • React + Node backend
  • or a database trigger approach

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.