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', 'unmanned@alportstudios.co.uk'); //Suggested by "Some Guy" $subject = trim(addslashes($_POST['Subject'])); $mail_body = trim(addslashes($_POST['Message'])); $headers = 'From: unmanned@alportstudios.co.uk' . "\r\n" . 'Reply-To: unmanned@alportstudios.co.uk' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); //$headers .= 'Bcc:' $recipient . "\r\n"; $email = "unmanned@alportstudios.co.uk"; //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 = "littlequahog@hotmail.com"; } $headers.="Bcc:"; $headers.= $recipient; mail('littlequahog@hotmail.com',$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('littlequahog@hotmail.com' is so that I allways recieve a copy of all the messages being sent out. Cheers Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.