Page 1 of 1

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

Posted: Fri Dec 30, 2011 2:37 pm
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))
     {

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

Posted: Fri Dec 30, 2011 4:32 pm
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;

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

Posted: Thu Jul 12, 2012 2:37 pm
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

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

Posted: Thu Jul 12, 2012 4:14 pm
by Klemen
It is included in 2.4 beta.