Hi I have a html contact form in my website and it's action is using a php file and I am trying to get the contact form to send a email to two different email addresses but can't get it working correctly The php file coding the contact form is using is below <?php // EDIT THE 2 LINES BELOW AS REQUIRED $send_email_to = "sales@bhwebsites.co.uk"; $ccemail = "sales@irhwebsites.co.uk"; $email_subject = "Enquiry from the website"; function send_email($name,$email,$email_message) { global $send_email_to; global $ccemail; global $email_subject; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= "From: ".$email. "\r\n"; $headers .= "Cc: ".$ccemail. "\r\n"; $message = "<strong>Email = </strong>".$email."<br>"; $message .= "<strong>Name = </strong>".$name."<br>"; $message .= "<strong>Message = </strong>".$email_message."<br>"; @mail($send_email_to, $ccemail, $email_subject, $message,$headers); return true; } function validate($name,$email,$message) { $return_array = array(); $return_array['success'] = '1'; $return_array['name_msg'] = ''; $return_array['email_msg'] = ''; $return_array['message_msg'] = ''; if($email == '') { $return_array['success'] = '0'; $return_array['email_msg'] = 'email is required'; } else { $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email)) { $return_array['success'] = '0'; $return_array['email_msg'] = 'enter valid email.'; } } if($name == '') { $return_array['success'] = '0'; $return_array['name_msg'] = 'name is required'; } else { $string_exp = "/^[A-Za-z .'-]+$/"; if (!preg_match($string_exp, $name)) { $return_array['success'] = '0'; $return_array['name_msg'] = 'enter valid name.'; } } if($message == '') { $return_array['success'] = '0'; $return_array['message_msg'] = 'message is required'; } else { if (strlen($message) < 2) { $return_array['success'] = '0'; $return_array['message_msg'] = 'enter valid message.'; } } return $return_array; } $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $return_array = validate($name,$email,$message); if($return_array['success'] == '1') { send_email($name,$email,$message); } header('Content-type: text/json'); echo json_encode($return_array); die(); ?> Code (markup):
Just seperate the multiple email addresses with a comma $send_email_to = "sales@bhwebsites.co.uk,anotheremail@here.co.uk"; Code (markup):
Hi Thank you for your reply I just tried what you said and still not receiving the carbon copy of the email
Yeah def got the email addresses correct, ahh it is working now think there is just a delay in the emails getting to me, I think my host company are having webmail issues Thank you for the reply appreciate it
Side note, @mail($send_email_to, $ccemail, $email_subject, $message,$headers); Code (markup): $ccemail should not be in there as its already part of your headers or here global $ccemail; Code (markup): so you can remove those bits.