This is the section of code which processes the email & sends it: -
//go ahead only if all fields are ok
if (empty($missing))
{
//build the message
$message = "Account no: $account_no<br/><hr />";
$message .= "Email: $email<br/><hr />";
$message .= "Order No: $order_no<br/><hr />";
$message .= "Date: $date<br/><hr />";
if (!empty($payment_method))
{
$message .= "Payment method: $payment_method<br/><hr />";
}
$message .= "Order taken by: $order_taken_by<br/><hr />";
$message .= "Account name: $account_name<br/><hr />";
$message .= "Company name: $company_name<br/><hr />";
if (!empty($account_address))
{
$message .= "Account address: $account_address<br/><hr />";
}
$message .= "Delivery address: $delivery_address<br/><hr />";
if (!empty($dealer_contact_name))
{
$message .= "Dealer contact name: $dealer_contact_name<br/><hr />";
}
$message .= "End user contact name: $delivery_user_contact_name<br/><hr />";
if (!empty($dealer_telephone_no))
{
$message .= "Dealer telephone no: $dealer_telephone_no<br/><hr />";
}
$message .= "End user telephone no: $delivery_user_telephone_no<br/><hr />";
$message .= "(1) Trust stock code: $trust_stock_code_one<br/>";
$message .= "(1) Supplier stock code: $supplier_stock_code_one<br/>";
$message .= "(1) Product description: $product_description_one<br/>";
$message .= "(1) Product colour: $product_colour_one<br/>";
$message .= "(1) Product quantity: $product_quantity_one<br/><hr />";
if (!empty($trust_stock_code_two))
{
$message .= "(2) Trust stock code: $trust_stock_code_two<br/>";
$message .= "(2) Supplier stock code: $supplier_stock_code_two<br/>";
$message .= "(2) Product description: $product_description_two<br/>";
$message .= "(2) Product colour: $product_colour_two<br/>";
$message .= "(2) Product quantity: $product_quantity_two<br/><hr />";
}
if (!empty($trust_stock_code_three))
$message .= "(3) Trust stock code: $trust_stock_code_three<br/>";
$message .= "(3) Supplier stock code: $supplier_stock_code_three<br/>";
$message .= "(3) Product description: $product_description_three<br/>";
$message .= "(3) Product colour: $product_colour_three<br/>";
$message .= "(3) Product quantity: $product_quantity_three<br/><hr />";
}
if (!empty($trust_stock_code_four))
{
$message .= "(4) Trust stock code: $trust_stock_code_four<br/>";
$message .= "(4) Supplier stock code: $supplier_stock_code_four<br/>";
$message .= "(4) Product description: $product_description_four<br/>";
$message .= "(4) Product colour: $product_colour_four<br/>";
$message .= "(4) Product quantity: $product_quantity_four<br/><hr />";
}
if (!empty($trust_stock_code_five))
{
$message .= "(5) Trust stock code: $trust_stock_code_five<br/>";
$message .= "(5) Supplier stock code: $supplier_stock_code_five<br/>";
$message .= "(5) Product description: $product_description_five<br/>";
$message .= "(5) Product colour: $product_colour_five<br/>";
$message .= "(5) Product quantity: $product_quantity_five<br/><hr />";
}
$message .= "Service required: $delivery_service<br/><hr />";
if (!empty($special_instructions))
{
$message .= "Special instructions: $special_instructions";
}
//limit line length to 70 characters
$message = wordwrap($message, 70);
//setting up the smtp authentication
require('class.phpmailer.php');
$mail = new PHPMailer();
$mail->SetLanguage('en', '/phpmailer/language/phpmailer.lang-en.php');
$mail->IsSMTP();
$mail->Host = 'my.isp.com';
$mail->SMTPAuth = true;
$mail->Username = 'my.email@address.com';
$mail->Password = 'Password';
$mail->From = $email;
$mail->FromName = $order_taken_by;
$mail->AddAddress('my.email@address.com','Purchasing');
$mail->IsHTML(true);
$mail->Subject = 'Sales Order Form';
$mail->Body = $message;
}
Now, when I change the From element (highlighted in red) to my email address which is included in the English language script you need to include with PHP mailer the form sends fine.
If I want to use the $email variable which would equal the users email address I get the error.
What I want to achieve is for the user to enter their email address in the form so when the results end up in my email box I can just hit the reply button to send the user a reply.
I hope i'm making sense.