Update tools.py

Fixed email date header not respecting the RFC2822 defined format

See:
https://groups.google.com/forum/#!topic/web2py/0Mb99H9kJOw
This commit is contained in:
Leonel Câmara
2014-02-25 12:29:51 +00:00
parent 36303e338d
commit 752a1c7df6

View File

@@ -23,6 +23,7 @@ import urllib2
import Cookie
import cStringIO
import ConfigParser
import email.utils
from email import MIMEBase, MIMEMultipart, MIMEText, Encoders, Header, message_from_string, Charset
from gluon.contenttype import contenttype
@@ -666,8 +667,7 @@ class Mail(object):
if bcc:
to.extend(bcc)
payload['Subject'] = encoded_or_raw(subject.decode(encoding))
payload['Date'] = time.strftime("%a, %d %b %Y %H:%M:%S +0000",
time.gmtime())
payload['Date'] = email.utils.formatdate()
for k, v in headers.iteritems():
payload[k] = encoded_or_raw(v.decode(encoding))
result = {}