riskmod
04-15-2008, 04:59 PM
I have this :
<?php
$msa = mysql_connect('server','id','pw') or die(mysql_error());
@mysql_select_db('myDB');
$getEmails = "SELECT store_id, id2 FROM stores";
$ansEmails = mysql_query($getEmails) or die(mysql_error());
$emailToString = '';
while($data = mysql_fetch_assoc($ansEmails)){
$emailToString .= " ".$data['store_id']."";
}
$getArticle = "SELECT * FROM stores";
$ansArticle = mysql_query($getArticle) or die(mysql_error());
$article = mysql_fetch_assoc($ansArticle);
mysql_free_result($ansEmails);
mysql_free_result($ansArticle);
$to = "youemail";
$subj = "Test mail";
$from = "From: myemail";
$headers = "From: $from\r\n";
$emailBodyString = " Test " . $article['some data colum from stores'] . " this stuff";
ini_set('SMTP', 'relay');
ini_set("smtp_port", 25);
mail($to, $subj, $emailBodyString, $from, $headers);
?>
Everything works but.....
I need to send this email to a bunch of our clients:
the easy thing is the data that I'm grabbing from the sql has the store_id that matches the persons email. So:
store_id: 1
email: gc1@domain.com
store_id: 2
email: gc2@domain.com
and etc.
I know to get the email and its right data itwould be like this(not sure if right):
$eMails = Array('gc'.store_id.'\@domain.com';);
for ($x = 0; $x < count($eMails); $x++) {
// code here
}
and to loop something like this:
for ($x = 1; $x < 400; $x++) {
$to = 'gc'.$x.'\@domain.com';
}
If so, I just need to know where and how you place these on the code I have.
If this work I might not even need the $emailToString that I started...
Thanks!
<?php
$msa = mysql_connect('server','id','pw') or die(mysql_error());
@mysql_select_db('myDB');
$getEmails = "SELECT store_id, id2 FROM stores";
$ansEmails = mysql_query($getEmails) or die(mysql_error());
$emailToString = '';
while($data = mysql_fetch_assoc($ansEmails)){
$emailToString .= " ".$data['store_id']."";
}
$getArticle = "SELECT * FROM stores";
$ansArticle = mysql_query($getArticle) or die(mysql_error());
$article = mysql_fetch_assoc($ansArticle);
mysql_free_result($ansEmails);
mysql_free_result($ansArticle);
$to = "youemail";
$subj = "Test mail";
$from = "From: myemail";
$headers = "From: $from\r\n";
$emailBodyString = " Test " . $article['some data colum from stores'] . " this stuff";
ini_set('SMTP', 'relay');
ini_set("smtp_port", 25);
mail($to, $subj, $emailBodyString, $from, $headers);
?>
Everything works but.....
I need to send this email to a bunch of our clients:
the easy thing is the data that I'm grabbing from the sql has the store_id that matches the persons email. So:
store_id: 1
email: gc1@domain.com
store_id: 2
email: gc2@domain.com
and etc.
I know to get the email and its right data itwould be like this(not sure if right):
$eMails = Array('gc'.store_id.'\@domain.com';);
for ($x = 0; $x < count($eMails); $x++) {
// code here
}
and to loop something like this:
for ($x = 1; $x < 400; $x++) {
$to = 'gc'.$x.'\@domain.com';
}
If so, I just need to know where and how you place these on the code I have.
If this work I might not even need the $emailToString that I started...
Thanks!