Hi everyone!
I devised a script that would send an email to all our customers.
The idea is that it will get all email addresses from a table (testcust) and send each one a unique email message (I do not want people to see other email adresses in the 'to' line).
I'm experiencing 3 problems with it though:
1) Although I see that the while loop is looping, (because the counter inside of it is properly incremented) doesn't look like its looping thru all the eamil addresses in my database, just sending to the first one in the list.
2) Sending to anybody@hotmail is a pain, either they don't get it at all, or...
3)They'll get it in the trash can and the image I'm enclosing in the message is hidden.
Here is the syntax from after my connection info:
$get_all_address = "SELECT eadd FROM testcust";
$result = @mysql_query($get_all_address, $connection)or die(mysql_error());
//lets record for admin people how many emails were sent so set up counter..
$counter="0";
while ($row = mysql_fetch_array($result)) {
$counter++;
$mailheaders = "MIME-Version: 1.0\n";
$mailheaders .= 'Content-Type: multipart/alternative; boundary="XXMail12345";';
$mailheaders .="From:info@washny.com <\"info@washny.com\">\n";
$mailheaders .="Reply-To:info@washny.com\n\n";
//create a multipart message
$body = "\r\n--XXMail12345\r\n";
//plain text first
$body .= "Content-type: text/plain; charset=iso-8859-1\r\n\r\n";
$body .= "We at Washington Deluxe Bus Co. are always ready to serve you with our famous daily Bus service between Washington DC and New York. Visit and click the \"Schedule & Stops\" link to view our special Thanksgiving season schedule";
$body .= "\r\n--XXMail12345\r\n";
$body .= "Content-type: text/html; charset=iso-8859-1\r\n\r\n";
//Then the HTML part
$body .= "<html><head><style type=\"text/css\" media=\"screen\"><!--
h6 { color: #00639c; font-size: 9pt; font-family: Verdana }
h5 { color: #00639c; font-size: 12pt; font-family: Verdana }
--></style></head><body>
<div align=\"center\">
<img src=\" height=\"164\" width=\"461\" border=\"0\"></div>
<h5>We at Washington Deluxe Bus Co. are always ready to serve you with our famous daily Bus service between Washington DC and New York.
<br>Please check out our special schedule for the Thanksgiving season - Nov 25-30 2003 - by clicking <a href=\" <h6>If you wish to be removed from our mailing list and not receive such emails from us in the future - Please click <a href=\" align=\"center\"></h6>
</div></body></html>";
$body .= "\r\n--XXMail12345--\r\n";
$to ="$row[eadd]";
$subject ="Check out our Thanksgiving season schedule";
//now send the mail
mail($to, $subject, $body, $mailheaders);
}
?>
I devised a script that would send an email to all our customers.
The idea is that it will get all email addresses from a table (testcust) and send each one a unique email message (I do not want people to see other email adresses in the 'to' line).
I'm experiencing 3 problems with it though:
1) Although I see that the while loop is looping, (because the counter inside of it is properly incremented) doesn't look like its looping thru all the eamil addresses in my database, just sending to the first one in the list.
2) Sending to anybody@hotmail is a pain, either they don't get it at all, or...
3)They'll get it in the trash can and the image I'm enclosing in the message is hidden.
Here is the syntax from after my connection info:
$get_all_address = "SELECT eadd FROM testcust";
$result = @mysql_query($get_all_address, $connection)or die(mysql_error());
//lets record for admin people how many emails were sent so set up counter..
$counter="0";
while ($row = mysql_fetch_array($result)) {
$counter++;
$mailheaders = "MIME-Version: 1.0\n";
$mailheaders .= 'Content-Type: multipart/alternative; boundary="XXMail12345";';
$mailheaders .="From:info@washny.com <\"info@washny.com\">\n";
$mailheaders .="Reply-To:info@washny.com\n\n";
//create a multipart message
$body = "\r\n--XXMail12345\r\n";
//plain text first
$body .= "Content-type: text/plain; charset=iso-8859-1\r\n\r\n";
$body .= "We at Washington Deluxe Bus Co. are always ready to serve you with our famous daily Bus service between Washington DC and New York. Visit and click the \"Schedule & Stops\" link to view our special Thanksgiving season schedule";
$body .= "\r\n--XXMail12345\r\n";
$body .= "Content-type: text/html; charset=iso-8859-1\r\n\r\n";
//Then the HTML part
$body .= "<html><head><style type=\"text/css\" media=\"screen\"><!--
h6 { color: #00639c; font-size: 9pt; font-family: Verdana }
h5 { color: #00639c; font-size: 12pt; font-family: Verdana }
--></style></head><body>
<div align=\"center\">
<img src=\" height=\"164\" width=\"461\" border=\"0\"></div>
<h5>We at Washington Deluxe Bus Co. are always ready to serve you with our famous daily Bus service between Washington DC and New York.
<br>Please check out our special schedule for the Thanksgiving season - Nov 25-30 2003 - by clicking <a href=\" <h6>If you wish to be removed from our mailing list and not receive such emails from us in the future - Please click <a href=\" align=\"center\"></h6>
</div></body></html>";
$body .= "\r\n--XXMail12345--\r\n";
$to ="$row[eadd]";
$subject ="Check out our Thanksgiving season schedule";
//now send the mail
mail($to, $subject, $body, $mailheaders);
}
?>