0

I have been using smtplib for Python and task schedulers to send emails using one of my gmail accounts. Sometimes, like twice in the past 2 weeks, my email delivery gets delayed. I thought it might be a network issue the first time, but it happened again yesterday and prompted me to check the mail headers. The headers are attached if anyone finds them helpful.

Ideally, each email should be sent over TLS as i am using the starttls() method after creating the SMTP object. I don't know if negotiating a secure connection is failing? The one which has no from headers is the email which was delayed by 1 hour and 20 minutes.

The email header should be something like:

Return-Path: <xxx.abc@gmail.com>
Received: from <ip-address-of-my-domain-here>
        by smtp.gmail.com with ESMTPSA id k9sm1110649pgo.33.2018.01.02.23.29.21
        for <xx.y@gmail.com>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 02 Jan 2018 23:29:22 -0800 (PST)
Message-ID: <5a4c8652.4950650a.5434e.2da0@mx.google.com>
Date: Tue, 02 Jan 2018 23:29:22 -0800 (PST)
From: <xxx.abc@gmail.com>
To: <xx.y@gmail.com>
Subject: <Email Subject here>

Instead it is this:

MIME-Version: 1.0
Received: by 10.28.34.8 with HTTP; Tue, 2 Jan 2018 23:50:59 -0800 (PST)
Date: Wed, 3 Jan 2018 15:50:59 +0800
Delivered-To: <xxx.abc@gmail.com>
Message-ID: <CACQ0ydCgZTbUb+P2XLj0i-QjS1o=d4HiOFrhU2JWsNPxpsScCA@mail.gmail.com>
Subject: <Email Subject here>
From: <xxx.abc@gmail.com>
To: <xx.y@gmail.com>
Content-Type: multipart/alternative; boundary="089e082ff6f0e5fc150561da7937"

--089e082ff6f0e5fc150561da7937
Content-Type: text/plain; charset="UTF-8"

delayed_email_headers on_time_email_headers

Any help or suggestions as to what might be going wrong would be great!

Adeel Siddiqui
  • 676
  • 7
  • 16
  • It's not clear what the images are supposed to convey or where exactly the two headers are significantly different. Could you please [edit] the question to draw our attention in the right direction? – tripleee Jan 10 '18 at 04:54
  • Having said that, there is no particular guarantee for near-immediate delivery in SMTP. In practice, greylisting can introduce significant delays and there is no way to influence that programmatically. – tripleee Jan 10 '18 at 04:55

0 Answers0