PDA

View Full Version : How to make extended characters work with osTicket


breakdaice
01-09-2008, 10:45 AM
Hey there!

Simple tweak to get full UTF-8 support to emails sent by osTicket:

original code:
/* Send email out after minor cleanups..*/
function sendmail($to, $subject, $message, $from, $headers = '') {

//TODO: provide an option to use SMTP server. Log all outgoign emails??
//do some cleanup...avoid stupid errors.
$to=preg_replace("/(\r\n|\r|\n)/s",'', trim($to));
$subject=preg_replace("/(\r\n|\r|\n)/s",'', trim($subject));
$message = preg_replace("/(\r\n|\r)/s", "\n", trim($message));
$headers = "From: $from \r\n" . $headers;
$headers = "Sender: $from \r\n" . $headers;
$headers = "X-Mailer: osTicket 1.6 \r\n" . $headers;
//echo "[$to,$subject,$message ".$headers.']';
mail($to,$subject,$message,trim($headers));


modified code:

/* Send email out after minor cleanups..*/
function sendmail($to, $subject, $message, $from, $headers = '') {

//TODO: provide an option to use SMTP server. Log all outgoign emails??
//do some cleanup...avoid stupid errors.
$to=preg_replace("/(\r\n|\r|\n)/s",'', trim($to));
$subject=preg_replace("/(\r\n|\r|\n)/s",'', trim($subject));
$message = preg_replace("/(\r\n|\r)/s", "\n", trim($message));
$headers = "From: $from \r\n" . $headers;
$headers = "Sender: $from \r\n" . $headers;
$headers = "X-Mailer: osTicket 1.6 \r\n" . $headers;
$headers = "Content-Type: text/plain;\n\tcharset=\"utf-8\"\r\n" . $headers;
$headers = "Content-Transfer-Encoding: 8bit\r\n" . $headers;
//echo "[$to,$subject,$message ".$headers.']';
mail($to,$subject,$message,trim($headers));

jeyenne
01-09-2008, 01:49 PM
And the file I have to modify to get full UTF-8 suport is?

4ice
01-09-2008, 02:24 PM
This is in the file ./include/class.misc.php

But breakdaice, why is your echo not commented? I guess this was for testing?

breakdaice
01-09-2008, 08:35 PM
This is in the file ./include/class.misc.php

But breakdaice, why is your echo not commented? I guess this was for testing?

True! ;)
My mistake....

4ice
01-09-2008, 09:26 PM
True! ;)
My mistake....

:) I thought so.

But is the "from address" etc correct with emails sent by osTicket. Because in my case the sender is still blank and all the header info is inside the email body.

I still have to figure out what's going wrong, but is probably a small issue.

breakdaice
01-11-2008, 03:54 PM
But is the "from address" etc correct with emails sent by osTicket. Because in my case the sender is still blank and all the header info is inside the email body.

I still have to figure out what's going wrong, but is probably a small issue.

Hmmm... Didn't actually notice that... Don't use Outlook ;)
But RFC states that the correct way would be to replace this:

$to=preg_replace("/(\r\n|\r|\n)/s",'', trim($to));
with this:

$to=preg_replace("/(\r\n|\r|\n)/s",'', trim($to));
$to="$to <$to>";

Though it would be nice to pass $recipient_name & $senders_name to that function too...
That way we could display a bit more eye friendly name 'cause we've got it in the db already!

:)

eliosh
01-17-2008, 03:13 PM
Will this patch be available in next RC ?
Because i have the same problem : with browser i have correct enconding, in emails (Thunderbird) i have strange chars...

e.g. : è ==> Ú

I confirm also what 4ice said :
Because in my case the sender is still blank and all the header info is inside the email body.
Tnx

eliosh
01-17-2008, 03:27 PM
this is the email dump :


...
Received: by mail.domain.ext (Postfix, from userid 33)
id 7818616C008; Thu, 17 Jan 2008 16:10:31 +0100 (CET)
To: #####@gmail.com
Subject: [#844352] Oggetto del ticket
X-Mailer: osTicket 1.6

Sender: noreply@####.it

From: noreply@####.it
Message-Id: <20080117151031.7818616C008@mail.domain.ext>
Date: Thu, 17 Jan 2008 16:10:31 +0100 (CET)

pippo baudo,pippo baudo is the account name (so, it's body's first line)

torusturtle
01-30-2008, 12:36 AM
Using osTicket 1.6 RC3 I hadd to change the email header settings to this:

$headers .= "Content-Type: text/plain; charset=utf-8".$eol;
$headers .= "Content-Transfer-Encoding: 8bit".$eol;

It would be great if this could be added to RC4

raffy
02-15-2008, 07:28 PM
Hello, I'm new of Osticket, and I have problem with accented chars (Italian). Does it works also for piping method?

wibi
02-16-2008, 03:03 PM
Same issue for me.
I did the modification but i receive the alert with a blank "From".

My code :

/* Send email out after minor cleanups..*/
function sendmail($to, $subject, $message, $fromaddress,$fromname='', $xheaders = '') {
//TODO: provide an option to use SMTP server. Log all outgoign emails??

$eol="\n";
$fromname=$fromname?$fromname:$fromaddress;
//do some cleanup...avoid stupid errors.
$to=preg_replace("/(\r\n|\r|\n)/s",'', trim($to));
$to="$to <$to>";
$subject=preg_replace("/(\r\n|\r|\n)/s",'', trim($subject));
$message = preg_replace("/(\r\n|\r)/s", "\n", trim($message));
#Headers
$headers .= "From: ".$fromname."<".$fromaddress.">".$eol;
$headers .= "Reply-To: ".$fromname."<".$fromaddress.">".$eol;
$headers .= "Return-Path: ".$fromname."<".$fromaddress.">".$eol;
$headers .= "Message-ID: <".time()."-".$fromaddress.">".$eol;
$headers .= "X-Mailer: OsTicket Support System".$eol;
$headers = "Content-Type: text/plain;\n\tcharset=\"utf-8\"\r\n" . $headers;
if($xheaders) $headers .= $xheaders;
//echo "[$to,$subject,$message ".$headers.']';
mail($to,$subject,$message,trim($headers));

Somebody can help ??

wibi
02-16-2008, 03:22 PM
Ok .. I did some test, and it seem working with a little modification :

my modified code :

/* Send email out after minor cleanups..*/
function sendmail($to, $subject, $message, $fromaddress,$fromname='', $xheaders = '') {
//TODO: provide an option to use SMTP server. Log all outgoign emails??

$eol="\n";
$fromname=$fromname?$fromname:$fromaddress;
//do some cleanup...avoid stupid errors.
$to=preg_replace("/(\r\n|\r|\n)/s",'', trim($to));
$to="$to <$to>";
$subject=preg_replace("/(\r\n|\r|\n)/s",'', trim($subject));
$message = preg_replace("/(\r\n|\r)/s", "\n", trim($message));
#Headers
$headers .= "From: ".$fromname."<".$fromaddress.">".$eol;
$headers .= "Reply-To: ".$fromname."<".$fromaddress.">".$eol;
$headers .= "Return-Path: ".$fromname."<".$fromaddress.">".$eol;
$headers .= "Message-ID: <".time()."-".$fromaddress.">".$eol;
$headers .= "X-Mailer: HelpDesk WIBI".$eol;
$headers .= "Content-Type: text/plain;\n\tcharset=\"utf-8\"\r\n";
if($xheaders) $headers .= $xheaders;
//echo "[$to,$subject,$message ".$headers.']';
mail($to,$subject,$message,trim($headers));

saaiber
02-18-2008, 03:47 PM
Problem solved, I checked the bugtracker and found the solution.

Greetings,

Nic