Jump to content

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); }

 

}

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.