Working with E-Mail

It seems that the default when sending e-mail with Python is that the "Date" header is not set. This is fine with a lot of e-mail clients, as they just parse the "Received" headers and work it out. However some clients like Home | K-9 Mail for Android seem to use the "time received in the client" if the "Date" header is missing.

There is a simple fix, which is to add code like this:
msg.add_header('Date', email.utils.formatdate())
Which will add the UTC datetime to the e-mail header.