Incorrect date/time format used in emails sent by Hesk SMTP

Everything related to Hesk - helpdesk software

Moderator: mkoch227

Post Reply
Jack!
Posts: 1
Joined: Fri Dec 30, 2011 11:58 am

Incorrect date/time format used in emails sent by Hesk SMTP

Post by Jack! »

Emails sent by Hesk SMTP show an incorrect receival time (10 hrs ahead in my case) in my Roundcube webmail client. A short investigation shows that Hesk is composing this date/time in file inc\email_functions.inc.php with code:

Code: Select all

"Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z"),
Result: Thu, 29 Dec 2011 13:19:29 W. Europe Standard Time.

This is not according to RFC2822. IMHO it's better to use predefined date/time constants:

Code: Select all

"Date: " . date(DATE_RFC2822),
Result: Thu, 29 Dec 2011 13:19:29 +0100

Patch:

Code: Select all

--- email_functions.inc_original.php	2011-10-19 20:08:58.000000000 +0200
+++ email_functions.inc_new.php	2011-12-29 16:03:01.002121100 +0100
@@ -82,7 +82,7 @@
                 "Reply-To: $hesk_settings[noreply_mail]",
                 "Return-Path: $hesk_settings[webmaster_mail]",
 				"Subject: " . $subject,
-				"Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z"),
+				"Date: " . date(DATE_RFC2822),
                 "Content-Type: text/plain; charset=".$hesklang['ENCODING']
 			), $message))
     {
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Re: Incorrect date/time format used in emails sent by Hesk S

Post by Klemen »

Thanks for reporting this!

Here's a work-around using hesk_date() that also takes in account difference in timezones between server and user location (if server is in US and you want to use UK local time for example):

Code: Select all

$save_format = $hesk_settings['timeformat'];
$hesk_settings['timeformat']=DATE_RFC2822;

	if($smtp->SendMessage($hesk_settings['noreply_mail'],$to_arr,array(
				"From: $hesk_settings[noreply_mail]",
				"To: $to",
                "Reply-To: $hesk_settings[noreply_mail]",
                "Return-Path: $hesk_settings[webmaster_mail]",
				"Subject: " . $subject,
				"Date: ".hesk_date(),
                "Content-Type: text/plain; charset=".$hesklang['ENCODING']
			), $message))
    {
    	return true;
    }
	else
    {
    	$error = $hesklang['cnsm'].' '.$to;

		if ($hesk_settings['debug_mode'])
        {
        	$error .= "\n".$hesklang['error'].": ".$smtp->error."\n";
        }

		return $error;
    }

$hesk_settings['timeformat'] = $save_format;
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
alanf
Posts: 1
Joined: Thu Jul 12, 2012 2:19 pm

Re: Incorrect date/time format used in emails sent by Hesk S

Post by alanf »

Thanks for this fix, I have just started testing HESK and noticed this with SMTP and daylight saving time, which was causing and hour incorrect date.

This fix works fine, I hope it is being incorprated into the next release.

Alan
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Re: Incorrect date/time format used in emails sent by Hesk S

Post by Klemen »

It is included in 2.4 beta.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Post Reply