Jump to content

mail function inserting random characters!


Stom

Recommended Posts

Hello all,

 

I'm using the PHP mail function to send the contents of an order form to both the end-user and the website owner.

 

The script i have basically loops through the submitted items and adds to a string called $order:

 

for ($x=1; $x<($_POST['element_count']+1); $x++) {
	if ($_POST['option'.$x.'qty']!=="na" && $_POST['option'.$x.'qty']!=="") {
		$order.= "<tr><td>".$x."</td><td>";
		$prod = mysql_fetch_array(mysql_query("SELECT * FROM prod WHERE id = ".substr($_POST[$x.'_prod'],-3,3)));
		$cat = mysql_fetch_array(mysql_query("SELECT * FROM cat WHERE id = ".$prod['cat']));
		$order.= $cat['name']."</td><td>".$prod['name']."</td><td>".$_POST['option'.$x.'qty']; 
	$order.="</td></tr>";
	}
}

 

This just generates a big list of items, the quantity and then i use the following to mail them off:

 

$to      = 'customer@domain.com';
$subject = 'Website Order-form submission';
$message = $order;
$headers = 
		'From: orders@thedomain.co.uk' . "\n".
		'Reply-To:  orders@thedomain.co.uk'. "\n".
		'X-Mailer: PHP/' . phpversion() ."\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n\n";

mail($to, $subject, $message, $headers);

 

The $order string is also then written to the page so that the user can see on the website what they have ordered. The website version appears fine, but there's something going on with the emails that are sent out. for some random reason the emails are coming through with an exclamation mark and a space inserted at random intervals (eg "Fruit Bas! kets") although always in the same place. I've checked for any odd characters that have made their way into the database and there aren't any.

 

This is driving me up the wall, does anyone have any suggestions?

 

Many thanks in advance!

Link to comment
Share on other sites

Thank you for your reply drisate. Can you provide more information?

 

The odd characters only seem to appear in the parts generated by the form. I will often get several in only a few words. The rest of email displays fine.

Link to comment
Share on other sites

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.