Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Python sendmail reports time sent incorrectly.

Status
Not open for further replies.

petrosky

Technical User
Aug 1, 2001
512
AU
Hi There,
We have some processes that execute python scripts overnight.
At the end of the process and automated email is sent. We recently had to move to our ISP's SMTP server.

Now, emails seem to appear before the scheduled task runs!

I just ran the following as a test at exactly 3PM and it appeared in my inbox almost immediately but it showed the time sent as 2:54PM.

Code:
import smtplib

email_to = "xxx@xxxxxxxxxxxxxx.com.au"
email_from  = "it@xxxxxxxxxxxxxxxx.com.au"
password = 'xxxxxxxxxxxxxx'

smtpserver = "smpt.server.address"
emsg = "Should have the time sent."

session = smtplib.SMTP(smtpserver)
session.login(email_from,password)
smtpresult = session.sendmail(email_from, email_to, emsg)
session.quit()

Is the time sent controlled by the mail server or does anyone have any idea what could cause the apparent difference?

Thanks for any advice.

Peter.

Remember- It's nice to be important,
but it's important to be nice :)
 
I don't think this is a Python problem per se. The time on the SMTP header will be the system time on the server. You should check that time if you can.

_________________
Bob Rashkin
 
Hi Bob,

Thanks for your reply. I tried setting the time in the header by importing datetime but it still shows the incorrect time.

As it is only 6 mins and the script is working, I will leave it as it is.

Regards,

Peter.

Remember- It's nice to be important,
but it's important to be nice :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top