Prompt
How do I send order confirmation emails?
Latest observation
Oct 16, 2026
OpenAI APIWeb search: off
To send order confirmation emails, you typically need to do these 5 things:
-
Trigger the email when an order is placed
- After payment succeeds or the order is created, call your email-sending logic.
-
Use a transactional email provider
- Common options: SendGrid, Mailgun, Amazon SES, Postmark, Resend.
- These are better than normal marketing email tools for confirmations.
-
Create an email template
- Include key order details:
- Order number
- Customer name
- Items purchased
- Total price
- Shipping/billing address
- Estimated delivery
- Support/contact info
- Include key order details:
-
Send the email from your backend
- Don’t send it directly from the frontend, because email credentials must stay private.
- Use a server route, background job, or webhook handler.
-
Handle failures and retries
- Log errors and retry if sending fails.
- Make sure you don’t send duplicates.
Example flow
- Customer checks out
- Payment is confirmed
- Your server saves the order
- Your server sends an order confirmation email
- Customer receives the email immediately
Simple example in Node.js using Nodemailer
import nodemailer from "nodemailer";
const transporter = nodemailer.createTransport({
service: "gmail",
auth: {
user: process.env.EMAIL_USER,
pass: process.env.EMAIL_PASS,
},
});
await transporter.sendMail({
from: '"My Store" <orders@mystore.com>',
to: customerEmail,
subject: `Order Confirmation #${orderId}`,
html: `
<h1>Thanks for your order!</h1>
<p>Your order #${orderId} has been received.</p>
<p>Total: $${total}</p>
`,
});
Best practices
- Send from a verified domain
- Add branded templates
- Include a receipt/order summary
- Make sure your emails are mobile-friendly
- Add SPF, DKIM, and DMARC to improve deliverability
If you want, I can show you how to do this in:
- Node.js
- Python
- PHP
- Shopify
- WooCommerce
- Django / Flask
- Next.js