whelpton Posted March 14, 2009 Share Posted March 14, 2009 I am trying to mail all my users, I've just managed to cobble together the code from various sources, many of them on here and I thank everyone whos helped me. Trouble I'm having at the moment is that, obviously I cant have my users knowing each others email addresses, so I am trying to use BCC to send the mail, but it just isnt working so far. This is the code that Ive got. ini_set('sendmail_from', '[email protected]'); //Suggested by "Some Guy" $subject = trim(addslashes($_POST['Subject'])); $mail_body = trim(addslashes($_POST['Message'])); $headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); //$headers .= 'Bcc:' $recipient . "\r\n"; $email = "[email protected]"; //senders e-mail adress $result = mysql_query("SELECT DISTINCT Email FROM Users") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $recipient .= "$row[0], "; //$recipient = "[email protected]"; } $headers.="Bcc:"; $headers.= $recipient; mail('[email protected]',$subject, $mail_body, $headers,); echo 'Sucessfully sent emails to:'; echo $recipient; echo '<br><a href="index.php">Continue</a>'; ?> In case you were wondering, the mail('[email protected]' is so that I allways recieve a copy of all the messages being sent out. Cheers Link to comment https://forums.phpfreaks.com/topic/149412-php-mail-bcc/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.