[Python] Django send_mail() / EmailMessage with Gmail SMTP has 4-minute delay for new email...

Discussão em 'Python' iniciado por Stack, Julho 16, 2025.

  1. Stack

    Stack Membro Participativo

    I’m facing a consistent email delivery delay when using Django’s built-in send_mail() or EmailMessage functions with Gmail SMTP.

    Setup:

    • Backend: Django (tested with both send_mail() and EmailMessage)
    • SMTP: smtp.gmail.com with App Passwords
    • Recipients: New or first-time email addresses (e.g., new Gmail or company emails)
    • Sender: Personal Gmail account using App Password (not Google Workspace)
    • Observation:
      • Emails show up instantly in the sender's Sent folder.
      • Recipient receives the email after ~4 minutes delay, only on the first send.
      • On re-sending to the same recipient, delivery is almost instant.

    This is especially problematic for: Sign-up confirmation, OTP delivery, Real-time alerts or notifications

    ❌ What I’ve Tried:

    • Tested both old and new Gmail accounts.
    • Created new and old App Passwords.
    • Sent using both send_mail() and EmailMessage.
    • Tried different recipient domains (Gmail, Outlook, work domains, etc.).
    • Verified there’s no error or SMTP failure — just delay.

    Additional Notes:

    • The issue does not occur for known recipients.
    • SMTP works fine; it's the delivery to new recipients that lags.
    • Server is configured correctly, no IPv6 hangups.
    • Delay seems similar to what Gmail does with anti-phishing checks, but I'm unsure if there’s a Django-specific fix or workaround.

    ❓ Question:


    • Is this behavior normal when using Gmail SMTP via Django?


    • Is there a known workaround to eliminate or reduce this delay for new recipients?


    • Would using OAuth or switching to a transactional email provider (SendGrid, Mailgun, etc.) help eliminate this delay?

    Continue reading...

Compartilhe esta Página