sblake161189 Posted January 31, 2011 Share Posted January 31, 2011 Hi Guys, Basically, I have a long php script to calculate the nearest branch dependant on there postcode hence why $to = $branchemail at the end. It will send it to HQ if anything goes wrong as a safeguard. Here is a small piece of my php code: if (strlen($branchemail) == 0){ // Default Address if anything goes wrong $to = "hq@example.com"; } else { // The address of the branch to send to $to = $branchemail; } What I can't seem to do is also send the customer filling in the php form a copy of the email sent. The variable for the customers email is $email I have tried this and it doesn't seem to work either... // The address of the branch to send to $to = $branchemail; $to .= $email; } At the bottom of the script, there is this code to physically send the email. This also always sends a copy to hq aswell. echo "Thank you for contacting us, we have received your message and we aim to respond your very shortly."; mail($to, $subject, $body, $mailheader); // THIS LINE TO CC Email mail("hq@example.com", $subject, $body, $mailheader); } else { echo "There has been an error code 1. Please try again."; So basically I just can't get it to send a copy to the customer filling it in ($email) Any idea's because my mind has gone blank. Cheers, S Quote Link to comment https://forums.phpfreaks.com/topic/226222-to-branchemail-and-a-copy-to-the-customer/ Share on other sites More sharing options...
suma237 Posted January 31, 2011 Share Posted January 31, 2011 echo the variable $to Quote Link to comment https://forums.phpfreaks.com/topic/226222-to-branchemail-and-a-copy-to-the-customer/#findComment-1167787 Share on other sites More sharing options...
sblake161189 Posted January 31, 2011 Author Share Posted January 31, 2011 Quote echo the variable $to Thanks for the reply, where do I echo the $to ? Quote Link to comment https://forums.phpfreaks.com/topic/226222-to-branchemail-and-a-copy-to-the-customer/#findComment-1167788 Share on other sites More sharing options...
suma237 Posted January 31, 2011 Share Posted January 31, 2011 echo "Thank you for contacting us, we have received your message and we aim to respond your very shortly."; echo $to;die; mail($to, $subject, $body, $mailheader); Quote Link to comment https://forums.phpfreaks.com/topic/226222-to-branchemail-and-a-copy-to-the-customer/#findComment-1167791 Share on other sites More sharing options...
sblake161189 Posted January 31, 2011 Author Share Posted January 31, 2011 Quote echo "Thank you for contacting us, we have received your message and we aim to respond your very shortly."; echo $to;die; mail($to, $subject, $body, $mailheader); The booking_sent.php page then outputs (with no space): branch@example.comcustomer@something.com Somehow I need to seperate those with a ; to put it in the correct mail format I am assuming? This is using this code further up: // The address of the branch to send to $to = $branchemail; $to .= $email; } Quote Link to comment https://forums.phpfreaks.com/topic/226222-to-branchemail-and-a-copy-to-the-customer/#findComment-1167794 Share on other sites More sharing options...
suma237 Posted January 31, 2011 Share Posted January 31, 2011 please check these links http://forums.asmallorange.com/topic/11501-php-mail-cc-bcc-headers/ http://www.w3schools.com/PHP/func_mail_mail.asp. You need to modify the header to send cc Quote Link to comment https://forums.phpfreaks.com/topic/226222-to-branchemail-and-a-copy-to-the-customer/#findComment-1167797 Share on other sites More sharing options...
sblake161189 Posted January 31, 2011 Author Share Posted January 31, 2011 Sorted! Its not... // The address of the branch to send to $to = $branchemail; $to .= $email; } delete the $to .=$email I changed the mailheaders to: $mailheader = "From: $email" . "\r\n"; // Always CC Email to HQ $mailheader = "Cc: hq@example.com" . "\r\n"; // Customers copy $mailheader .= "BCc: $email" . "\r\n"; then mail($to, $subject, $body, $mailheader); Sorted! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/226222-to-branchemail-and-a-copy-to-the-customer/#findComment-1167841 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.