e.g. if the string contains:
1234 (5 spaces here) 1234 (5 spaces here) 1234
when the email arrives it looks like this:
1234 1234 1234
( I have had to put "(5 spaces here)" above in sample as this forum does the very same thing!!!)
Can any one advise why extra spaces in a string are removed?
the code I use is below
With thanks, Barry.
- Code: Select all
<?php
$name = $HTTP_POST_VARS['name'];
$order = $HTTP_POST_VARS['order'];
$ref_no = $HTTP_POST_VARS['ref_no'];
$phone = $HTTP_POST_VARS['phone'];
$cell = $HTTP_POST_VARS['cell'];
$email = $HTTP_POST_VARS['email'];
$required = $HTTP_POST_VARS['required'];
$message = $HTTP_POST_VARS['message'];
$item1 = $HTTP_POST_VARS['item1'];
$item2 = $HTTP_POST_VARS['item2'];
$item3 = $HTTP_POST_VARS['item3'];
$item4 = $HTTP_POST_VARS['item4'];
$item5 = $HTTP_POST_VARS['item5'];
$item6 = $HTTP_POST_VARS['item6'];
$item7 = $HTTP_POST_VARS['item7'];
$item8 = $HTTP_POST_VARS['item8'];
$item9 = $HTTP_POST_VARS['item9'];
$item10 = $HTTP_POST_VARS['item10'];
$item11 = $HTTP_POST_VARS['item11'];
$item12 = $HTTP_POST_VARS['item12'];
$item13 = $HTTP_POST_VARS['item13'];
$item14 = $HTTP_POST_VARS['item14'];
$item15 = $HTTP_POST_VARS['item15'];
$item16 = $HTTP_POST_VARS['item16'];
$item17 = $HTTP_POST_VARS['item17'];
$item18 = $HTTP_POST_VARS['item18'];
$item19 = $HTTP_POST_VARS['item19'];
$item20 = $HTTP_POST_VARS['item20'];
$total = $HTTP_POST_VARS['total'];
$header = $HTTP_POST_VARS['header'];
$trade = $HTTP_POST_VARS['trade'];
// Remove Slashes Inserted by PHP
$name = stripslashes($name);
$order = stripslashes($order);
$ref_no = stripslashes($ref_no);
$phone = stripslashes($phone);
$cell = stripslashes($cell);
$email = stripslashes($email);
$required = stripslashes($required);
$message = stripslashes($message);
$item1 = stripslashes($item1);
$item2 = stripslashes($item2);
$item3 = stripslashes($item3);
$item4 = stripslashes($item4);
$item5 = stripslashes($item5);
$item6 = stripslashes($item6);
$item7 = stripslashes($item7);
$item8 = stripslashes($item8);
$item9 = stripslashes($item9);
$item10 = stripslashes($item10);
$item11 = stripslashes($item11);
$item12 = stripslashes($item12);
$item13 = stripslashes($item13);
$item14 = stripslashes($item14);
$item15 = stripslashes($item15);
$item16 = stripslashes($item16);
$item17 = stripslashes($item17);
$item18 = stripslashes($item18);
$item19 = stripslashes($item19);
$item20 = stripslashes($item20);
$total = stripslashes($total);
$header = stripslashes($header);
$trade = stripslashes($trade);
// $phone = stripslashes($phone); // example of an additional input field
$headers = "From: $name <$email>";//put you own stuff here or use a variable
$to = "sales@xxxxxxxxx.co.nz, $email" ;// same as above
// Start Customizable Email Information
// Change the information in quotes below to fit your needs
$rec_email = "sales@xxxxxxxxx.co.nz, $email"; // who do you want to send this email to
$subject = "Canterbury Trellis Order Request - Your Order: $order - Our Ref: $ref_no"; // this is the subject line of the email
$html .="<img src='logo.gif'><br/><br />";
// Begin the HTML code - and display the place the form was sent from
$msg_body = "<html><head></head><body>";
$msg_body = "<font face=\"Verdana\" size=\"2\">";
// Display the information filled out in the contact form
//$html .= "<b><font face=\"Verdana\" size=\"2\">Company:</b> $company<br>";
//$html .= "<b>Branch:</b> $branch<br>";
$html .= "<b><font face=\"Verdana\" size=\"2\">Name:</b> $name<br>";
//$html .= "<b>Order Number:</b> $order<br>";
$html .= "<b>Reference Number:</b> $ref_no<br>";
$html .= "<b>Phone:</b> $phone<br>";
$html .= "<b>Cell:</b> $cell<br>";
$html .= "<b>Requred By:</b> $required<br>";
$html .= "<b>E-Mail:</b> <a href=\"mailto:$email\">$email</a><br>";
$html .= "<b>Notes:</b> $message<br>";
$html .= "<hr width=\"100%\" size=\"1\" color=\"#333333\"><br>";
$html .= "<font face=\"OCR\" size=\"1\"> Wide Deep high Base S-Lip Wood Leg Price<br>";
$html .= "<b><font face=\"Lucida Console\" size=\"2\">Item 1 =</b> $item1<br>";
$html .= "<b>Item 2 =</b> $item2<br>";
$html .= "<b>Item 3 =</b> $item3<br>";
$html .= "<b>Item 4 =</b> $item4<br>";
$html .= "<b>Item 5 =</b> $item5<br>";
$html .= "<b>Item 6 =</b> $item6<br>";
$html .= "<b>Item 7 =</b> $item7<br>";
$html .= "<b>Item 8 =</b> $item8<br>";
$html .= "<b>Item 9 =</b> $item9<br>";
$html .= "<b>Item 10 =</b> $item10<br>";
$html .= "<b>Item 11 =</b> $item11<br>";
$html .= "<b>Item 12 =</b> $item12<br>";
$html .= "<b>Item 13 =</b> $item13<br>";
$html .= "<b>Item 14 =</b> $item14<br>";
$html .= "<b>Item 15 =</b> $item15<br>";
$html .= "<b>Item 16 =</b> $item16<br>";
$html .= "<b>Item 17 =</b> $item17<br>";
$html .= "<b>Item 18 =</b> $item18<br>";
$html .= "<b>Item 19 =</b> $item19<br>";
$html .= "<b>Item 20 =</b> $item20<br>";
//$html .= "<b><font face=\"Verdana\" size=\"2\">$trade Total = </b> $total.00<br><br>";
$html .= "<b><font face=\"Verdana\" size=\"2\">Total = </b> $total.00<br>";
$html .= "<hr width=\"100%\" size=\"1\" color=\"#333333\">";
// Account payment details
$html .= "<b><font face=\"Verdana\" size=\"2\">Online payments can be made to:</b><br>";
$html .= "Canterbury Trellis Ltd<br>";
$html .= "Bank: Westpac<br>";
$html .= "Account Number: xx-xxxx-xxxxxx-xxx<br>";
$html .= "Refernce Number: $ref_no<br>";
// Add a little information about the person who sent this message
$html .= "<hr width=\"100%\" size=\"1\" color=\"#333333\"><br>";
$html .= "<b>IP Address:</b> $REMOTE_ADDR<br>";
$html .= "</font></body></html>";
//file to attach
$fileatt2 = 'images/logo.gif';//put the relative path to the file here on your server
$fileatt_name2 = 'logo.gif';//just the name of the file here
$fileatt_type2 = filetype($fileatt2);
$file2 = fopen($fileatt2,'rb');
$data2 = fread($file2,filesize($fileatt2));
fclose($file2);
// Generate a boundary string that is unique
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/alternative;\n" .
" boundary=\"{$mime_boundary}\"";
$message = "--{$mime_boundary}\n" .
"Content-Type: text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
"<font face=Arial>" .
$html."\r\n";
$message .= "--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
// Base64 encode the file data
$data2 = chunk_split(base64_encode($data2));
// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: image/gif;\n" . // {$fileatt_type}
" name=\"{$fileatt_name2}\"\n" .
"Content-Disposition: inline;\n" .
" filename=\"{$fileatt_name2}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data2 . "\n\n" .
"--{$mime_boundary}--\n";
// Send the message
mail($to, $subject, $message, $headers);
?>

