Burak Arslan added the comment:
turns out timetuple was not passing timezone information. the correct way of
converting a datetime.datetime object to a correct rfc-2822 compliant date
string seems to be:
email.utils.formatdate(time.mktime(a.utctimetuple()) + 1e-6 * a.microsecond
New submission from Burak Arslan :
There's an issue with email.utils.formatdate function, illustrated here:
https://gist.github.com/1321994
for reference i'm on Europe/Istanbul timezone, which is +03:00 because of DST
at the time of this writing.
I'm on stable Python 2.7.2