Transactional Email via SMTP

How to integrate and send transactional emails with guaranteed delivery

What Makes Email Transactional?

Transactional emails are automated, non-marketing messages triggered by a user action. They have the highest deliverability requirements because failure is immediately noticed by users.

Type Examples Latency Requirement
Authentication Password reset, 2FA codes Immediate
Transactional Order confirmation, receipt <30 seconds
Shipping Shipping notification, delivery update <5 minutes
Notification Payment received, subscription reminder <1 hour

SMTP Integration Options

Option 1: Direct SMTP Relay

# PHP Example $transport = (new Swift_SmtpTransport('smtp.cloudmails.eu', 587)) ->setUsername('your_username') ->setPassword('your_password') ->setEncryption('tls'); $mailer = new Swift_Mailer($transport); $message = (new Swift_Message('Password Reset')) ->setFrom(['noreply@yoursite.com' => 'YourSite']) ->setTo(['user@example.com']) ->setBody('Click here to reset: https://yoursite.com/reset?token=xyz'); // Send immediately $result = $mailer->send($message);

Option 2: REST API (Recommended)

# Python Example import requests response = requests.post('https://api.cloudmails.eu/v1/send', json={ 'to': 'user@example.com', 'from': 'noreply@yoursite.com', 'subject': 'Password Reset', 'html': '

Click here to reset your password.

', 'template': 'password-reset', 'variables': { 'reset_link': 'https://yoursite.com/reset?token=xyz', 'user_name': 'John' } }) print(response.json())

Reliability Requirements

⚠️ The 5-Second Rule

If your password reset email takes more than 5 seconds to send, users refresh and request another. Your email system must queue and deliver within 5 seconds at p99.

Essential Reliability Features

Queue-Based Sending

Never make the user wait for email delivery. Queue the email and return immediately. Process from queue asynchronously.

Automatic Retries

Transient failures (connection timeout, temporary ISP blocks) should retry automatically. Configure 3 retries with exponential backoff.

Delivery Webhooks

Receive callbacks when emails are delivered, bounce, or have complaints. Critical for monitoring and suppressing failed addresses.

Duplicate Prevention

Idempotent sends prevent duplicate password reset emails when users click multiple times.

Implementation Patterns

Password Reset Flow

1. User clicks "Forgot Password" 2. System generates token, stores with timestamp 3. Email sent via SMTP with reset link 4. User clicks link within 1 hour 5. Token validated, password reset form shown 6. New password hashed and stored 7. Token invalidated after use

Order Confirmation Flow

1. Order placed successfully in DB 2. Email job queued with order details 3. Return success to user immediately 4. Queue processor sends confirmation 5. If send fails, retry 3 times 6. Alert ops if all retries fail

Key Difference from Cold Email

Transactional email has different infrastructure requirements than cold email. Transactional needs immediate delivery and high reliability. Cold email needs reputation management and volume control. CloudMails handles both with separate optimized infrastructure.

Authentication for Transactional

Transactional emails should still use proper authentication:

  • SPF - Authorize your sending servers
  • DKIM - Sign emails cryptographically
  • DMARC - Monitor and enforce alignment
  • FROM address - Use your actual domain, not free providers

✅ CloudMails Transactional

CloudMails provides dedicated transactional infrastructure with 99.99% uptime SLA, sub-second delivery at p99, and automatic failover. Separate from cold email reputation.

Set Up Transactional Email →