...

View Full Version : php mail() multiple recipients



Tulungo
01-19-2010, 10:41 PM
Ok i got a problem, i need to select a name to include in the message
the code looks like this:


$data =date("m", time());
$data1=date("d",time());

mysql_select_db( $db, $link ) or die ( "Couldn't open $db: ".mysql_error() );
$result = mysql_query( "SELECT Nome, Email FROM funcionarios where extract(day from Data_de_Nascimento)='$data1' and extract(month from Data_de_Nascimento)='$data' order by Data_de_Nascimento" );
$num_rows = mysql_num_rows( $result );

while ( $row = mysql_fetch_array( $result ) )
{

$to .= $row[Email] . ',';
rtrim($to, ',');
$na .= $row[Nome] . ','; //Name
rtrim($na, ',');


}

$sub="Feliz aniversario";
ini_set('SMTP', 'mail.clix.pt');
$subject = "$sub";
$message = "Sr. $na a fastforward ................................ Feliz aniversario";
$headers = 'From: bitlo@clix.pt' . "\r\n" .
'Reply-To: bitlo@clix.pt' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);


But in the message it apears all the names, and i need to associte a name to a email.....
Can please some one HELP ME!!!!!

JAY6390
01-19-2010, 10:43 PM
If you want to assign names to email addresses you need to do it in the format
Joe Bloggs <joe@bloggs.com>

Tulungo
01-19-2010, 10:54 PM
If you want to assign names to email addresses you need to do it in the format
Joe Bloggs <joe@bloggs.com>

i need to get the names at Mysql:

"SELECT Nome, Email FROM funcionarios where extract(day from Data_de_Nascimento)='$data1' and extract(month from Data_de_Nascimento)='$data' order by Data_de_Nascimento" );


And i need to associte a name to a email:

while ( $row = mysql_fetch_array( $result ) )
{

$to .= $row[Email] . ',';
rtrim($to, ',');
$na .= $row[Nome] . ','; //Name
rtrim($na, ',');


}

Because in the message i got to put a text with is name on it:

$message = "Sr. $na a fastforward ................................ Feliz aniversario";



And they are a lot of Names....

So in one mail the message got all the names and i need to put the name in the right message.


Can please some one help me..



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum