I have been relentlessly trying to get this done but have not achieved success. I have a website form which is processed by a php script and email is sent to me. I want this email to be sent to two different email ids and want one of them to be bcc. I have this on bluehost linux servers. I would be really very much obliged if someone can help me out with this. My changed code is as follows <?php $email = Trim(stripslashes($_POST['email'])); $torecipient = "xxxww"; $header = "From: $email\r\n"; $header .= "Reply-to: $email\r\n"; $header .= "bcc: xxxx\r\n"; $txt1 = Trim(stripslashes($_POST['state'])); $txt2 = "State,Contact Form"; $Subject = $txt1 . " " . $txt2; $company = Trim(stripslashes($_POST['company'])); $address = Trim(stripslashes($_POST['address'])); $country = Trim(stripslashes($_POST['country'])); $state = Trim(stripslashes($_POST['state'])); $zip = Trim(stripslashes($_POST['zip'])); $contactno = Trim(stripslashes($_POST['contactno'])); $person = Trim(stripslashes($_POST['person'])); $email = Trim(stripslashes($_POST['email'])); $box1 = Trim(stripslashes($_POST['box1'])); $box2 = Trim(stripslashes($_POST['box2'])); $box3 = Trim(stripslashes($_POST['box3'])); $box4 = Trim(stripslashes($_POST['box4'])); $other = Trim(stripslashes($_POST['other'])); $comment = Trim(stripslashes($_POST['comment'])); $Body = ""; $Body .= "Company: "; $Body .= $company; $Body .= "\n"; $Body .= "Address: "; $Body .= $address; $Body .= "\n"; $Body .= "Country: "; $Body .= $country; $Body .= "\n"; $Body .= "State: "; $Body .= $state; $Body .= "\n"; $Body .= "Zip Code: "; $Body .= $zip; $Body .= "\n"; $Body .= "Contact No: "; $Body .= $contactno; $Body .= "\n"; $Body .= "Contact Person: "; $Body .= $person; $Body .= "\n"; $Body .= "Email: "; $Body .= $email; $Body .= "\n"; $Body .= "Mega: "; $Body .= $box1; $Body .= "\n"; $Body .= "HyPer: "; $Body .= $box2; $Body .= "\n"; $Body .= "Washer: "; $Body .= $box3; $Body .= "\n"; $Body .= "Other: "; $Body .= $box4; $Body .= "\n"; $Body .= "Other: "; $Body .= $other; $Body .= "\n"; $Body .= "Comments: "; $Body .= $comment; ini_set ("sendmail_from","<$email>"); // send email mail($torecipient, $Subject, $Body, $header); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=\">"; } ?> Please help me out with this. I am receiving the email to both email addresses but not as bcc.Both email ids are visible in the to header section of the email Please help
I think it should be $header .= "Bcc: xxxx\r\n"; PHP: No space bet ween quote and Bcc also I think \r\n is right rather than \n
try changing "From: $email" to "From:name@websitename.com " where websitename.com is the name of the website where this script is running. From address from the originating server is required for some email receivers.
I don't see any issues perse, but it's probably better to use a mail library instead of the built in functionality. Use http://swiftmailer.org/
Well, I actually switched to swiftmailer back in the day when it seemed like phpmailer development was stale. It seems that it is now in active development again, since I'm no longer using it I can't really give an honest comparison of the two. Swiftmailer does all I need and it has excellent documentation.