Mail not setting timestamp

  • Thread starter Lorenzo Thurman
  • Start date
L

Lorenzo Thurman

I'm using the Mimewriter and mimetools modules to create html messages.
They work OK, except that when the messages are received, they always
have the timestamp of 12/31/1969. I've looked through both packages and
can't find anything that would allow me to manually set it. Can someone
help me out?
TIA
 
G

Gabriel Genellina

Lorenzo said:
I'm using the Mimewriter and mimetools modules to create html messages.
They work OK, except that when the messages are received, they always
have the timestamp of 12/31/1969. I've looked through both packages and
can't find anything that would allow me to manually set it. Can someone
help me out?

The date goes into the message headers, like From, To, Subject...
message.add_header("Date", "Thu, 22 Jun 2006 23:18:15 -0300")
 
L

Lorenzo Thurman

Gabriel said:
The date goes into the message headers, like From, To, Subject...
message.add_header("Date", "Thu, 22 Jun 2006 23:18:15 -0300")
Thanks for the reply. When I try this though, I get an error:

Traceback (most recent call last):
File "./synctest.py", line 202, in ?
message = createhtmlmail(html, text, subject)
File "./synctest.py", line 49, in createhtmlmail
writer.addheader("Date", theDate)
File "/usr/lib/python2.4/MimeWriter.py", line 100, in addheader
lines = value.split("\n")
AttributeError: 'datetime.datetime' object has no attribute 'split'

I'm trying to use a variable for the date, since of course, it should
always be 'now'.
someDate = datetime.datetime.now()
writer.addheader("Date", someDate)
Hard coding a date, like your example, works just fine.
Any ideas?
 
G

Gabriel Genellina

Lorenzo said:
Thanks for the reply. When I try this though, I get an error:
AttributeError: 'datetime.datetime' object has no attribute 'split'
I'm trying to use a variable for the date, since of course, it should
always be 'now'.

You have to convert the date into a string, using the right format.
The docs for the time module have a recipe:
http://www.python.org/doc/current/lib/module-time.html
(look for RFC 2822)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top