Jump to content

$to = $branchemail and a copy to the customer


sblake161189

Recommended Posts

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 = "[email protected]";
}
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("[email protected]", $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

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):

 

[email protected]@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;
}

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: [email protected]" . "\r\n";
// Customers copy
$mailheader .= "BCc: $email" . "\r\n";

 

then

 

mail($to, $subject, $body, $mailheader);

 

Sorted!

Thanks!

Archived

This topic is now archived and is closed to further replies.

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