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 = "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

Link to comment
Share on other sites

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;
}

Link to comment
Share on other sites

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!

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.