On Tue, January 17, 2006 9:12 am, ET Support wrote: > I am having a problem using PHP's mail function to send mail via BCC > to > multiple recipients. Here's my code; > -------------------------------------- > $get_emails = pg_exec($dbh,"SELECT email FROM mailing_list WHERE conf > = 1"); > $count = pg_numrows($get_emails); > $bcc_count = $envelope_count = 0; > $bcc_limit = 200; > $subject = $body = 'test message'; > $from = 'support@xxxxxxxxxxxxxxx'; > $header = "From: $from\r\n"; You probably want Reply-to: here as well... > for($x = 0; $x < $count; $x++) { > $email = pg_result($get_emails,$x,0); > if($bcc_count >= $bcc_limit) { > if($x > 0) { > $envelope_count++; > mail($from,$subject,$body,$headers); > } > $headers = $header . "Bcc: $email\r\n"; > $bcc_count = 1; > } else { > $headers .= "Bcc: $email\r\n"; > $bcc_count++; > } > } > # send the last envelope > mail($from,$subject,$body,$headers); > -------------------------------------- > > The problem is that for some recipients they get a message body like > this; > > -------------------------------------- > Message-Id: <20060116170640.424CFA51997@xxxxxxxxxxxxxxx> > Date: Mon, 16 Jan 2006 17:06:40 +0000 (GMT) > > test message > -------------------------------------- > > Any idea why those headers are being inserted into the message body > and how > that can be prevented? If $email contains a newline, or a \r\n, then you might see that... Because your Bcc: $email\r\n turns into: Bcc: junk\n \r\n Message-Id: <....> At which point you're not in the heades any more because your 'email' forced you out of them with a blank line. How 'clean' are the emails in your database?... :-) If they've come from a web signup form, and you weren't validating the input, then I guarantee you've got spammers trying to use your form to send out junk by forcing newlines and the headers THEY want into your 'email' field... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php