Jump to content

[SOLVED] Sent emails displaying \r\n instead of line feed


santobugito

Recommended Posts

I have an issue with incorrectly formatted emails

 

On a form I enter the text

 

1

2

3

4

 

When saved to database it is saved a above, but when the email (html formatted via server 2003 smtp server) is sent, it comes out as

 

1\r\n2\r\n3\r\n4

 

I've tried doing a replace with <br> and <p> and also /n, but with no luck.

 

Any ideas on this would save my hair!

 

I have had the exact same problem a few times. What fixed it for me was to send the e-mail and then use mysql_real_escape_string() after the message has been sent rather than before. The escaping caused the same problem for me as the one you stated.

I have had the exact same problem a few times. What fixed it for me was to send the e-mail and then use mysql_real_escape_string() after the message has been sent rather than before. The escaping caused the same problem for me as the one you stated.

 

No luck on this one I now get

 

Message : \'b\\r\\nv\\r\\nc\\r\\nx\'

 

Also doing the replace in reply 1 didn't help either.

 

The code for generating the text is

 

function email_alert_assigned_only($tid, $msgid=false, $msg=false, $subject=false) { //alerts the alert_user (in mail)

global $config, $db_table;

 

$tid=preg_replace('/\D+/', '', $tid); //sanitise

$msgid=preg_replace('/\D+/', '', $msgid); //sanitise

 

if (empty($tid)) { return; }

 

$t = mysql_fetch_array(mysql_query("SELECT * FROM ".$db_table['tickets']." WHERE ID=".$tid));

$cat = get_category($t['cat']);

 

 

if (!empty($msgid)) {

$m = mysql_fetch_array(mysql_query("SELECT * FROM ".$db_table['messages']." WHERE ID=".$msgid));

}

 

$from = $config['alert_email'];

$alert_subj = str_replace("Message","Private Message",$config['alert_subj']);

//$alert_msg = "You have a new private message for ticket ".$tid."

$alert_msg = "There is a new private message for ticket %ticket

 

From: %name (%email)

 

Message : %message

 

http://site/admin.php?a=view&id=%ticket

 

%url

";

 

$vars=array();

$vars['ticket']=$t['ID'];

$vars['subject']=$subject? $subject: htmlspecialchars_decode($t['subject']);

$vars['category']=$cat['name'];

$vars['cat_name']=$cat['name'];

$vars['name']=$t['name'];

$vars['email']=$t['email'];

$vars['datetime']=(empty($m))?'': format_time('r', time_convert($m['timestamp']));

//$msg =  str_replace("'", "\"", $msg);

$vars['message']=$msg ? htmlspecialchars_decode($msg) : htmlspecialchars_decode($m['message']);

$alert_subj=Keywords($alert_subj,$vars);

$text=Keywords($alert_msg,$vars);

if ($html=GetHTML($alert_msg,$vars,'email.html')) {

$body=array();

$body['text']=$text;

$body['html']=$html;

}

else { $body['html']=text2html($text); }

 

$pri=$t['priority'] == 3?1:'';

 

        //replace bit below with get recipient

 

        $to = '';

 

        $rep=$t['rep'];

 

        if ($rep != "")

        {

          $rows = mysql_fetch_array(mysql_query("SELECT * FROM ".$db_table['reps']." WHERE ID=".$rep));

          $to = $rows['email'];

        }

 

        if (!empty($to)) { send_mail($to, $alert_subj, $body, $from, false, $pri); }

 

}

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.