Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mass Emailing Problem 1

Status
Not open for further replies.

smashing

Programmer
Joined
Oct 15, 2002
Messages
170
Location
US
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 .=&quot;From:info@washny.com <\&quot;info@washny.com\&quot;>\n&quot;;
$mailheaders .=&quot;Reply-To:info@washny.com\n\n&quot;;

//create a multipart message
$body = &quot;\r\n--XXMail12345\r\n&quot;;

//plain text first
$body .= &quot;Content-type: text/plain; charset=iso-8859-1\r\n\r\n&quot;;
$body .= &quot;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 \&quot;Schedule & Stops\&quot; link to view our special Thanksgiving season schedule&quot;;
$body .= &quot;\r\n--XXMail12345\r\n&quot;;
$body .= &quot;Content-type: text/html; charset=iso-8859-1\r\n\r\n&quot;;

//Then the HTML part
$body .= &quot;<html><head><style type=\&quot;text/css\&quot; media=\&quot;screen\&quot;><!--
h6 { color: #00639c; font-size: 9pt; font-family: Verdana }
h5 { color: #00639c; font-size: 12pt; font-family: Verdana }
--></style></head><body>
<div align=\&quot;center\&quot;>
<img src=\&quot; height=\&quot;164\&quot; width=\&quot;461\&quot; border=\&quot;0\&quot;></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=\&quot; <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=\&quot; align=\&quot;center\&quot;></h6>

</div></body></html>&quot;;
$body .= &quot;\r\n--XXMail12345--\r\n&quot;;


$to =&quot;$row[eadd]&quot;;
$subject =&quot;Check out our Thanksgiving season schedule&quot;;

//now send the mail
mail($to, $subject, $body, $mailheaders);
}
?>
 
Hi Sleipnir214, Long time no speak!
All the recipients in the testcust table are me! I've put 4 of my own email addresses in there. So I can see that only the first one in there gets it. Once I get this up and running I'll switch the table name to my real table where I have thousands of email adresess.
Another thing to note here is that of the 4 in the testcust table, 2 are duplicates, so if it would've looped I should've gotton it twice.
Thanks
 
Humor me. Put a print statement in there somewhere so that we can be absolutely sure whether the loop is working as it should. Lots of things can be happening between your script and your mail client.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
OK I added this inside the loop:

$form_fields .= &quot;<tr>
<td><h6>&quot; . $row[eadd]. &quot;</h6></td>
</tr>&quot;;

and it does print out all the 4 entries in that are in the table.
 
perhaps you're provider has installed something to prevent mass emailings ;)

have you also tried to built in a delay of a few seconds ?
 
smashing:
Then the app is running right. The problem with the undelivered mails appears to be something with your mail server.


As far as sending to hotmail.com goes, good luck. They have some tough spam filters and they are not talking about how they work. It's probably a missing SMTP header or something.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Thanks
&quot;It's probably a missing SMTP header or something. &quot;
If you could look into it and see what I can try and change in the SMTP header or what not, I'd very much appreciate.
Thanks
 
I hear ya, I'm in this business too!
But taking a look at these 5 lines or so have I gone wrong so fat?

$mailheaders = &quot;MIME-Version: 1.0\n&quot;;
$mailheaders .= 'Content-Type: multipart/alternative; boundary=&quot;XXMail12345&quot;;';
$mailheaders .=&quot;From:info@washny.com <\&quot;info@washny.com\&quot;>\n&quot;;
        $mailheaders .=&quot;Reply-To:info@washny.com\n\n&quot;;        
//create a multipart message
$body = &quot;\r\n--XXMail12345\r\n&quot;;
//plain text first
$body .= &quot;Content-type: text/plain; charset=iso-8859-1\r\n\r\n&quot;;
 
Again, I cannot say. One thing I recommend when creating complex email messages in PHP is to use PHPMailer:

Keep in mind that my reference to headers was in the context of &quot;probably a missing SMTP header or something&quot;. From this you can infer that I was speculating.

For all I know, it has nothing whatsoever to do with your SMTP headers. It could be that your mail server is on a hotmail blackhole list. It could be that the domain in your replay-to address can't be found. It could be that there's no reverse DNS entry for your mail server. Lots of things can trip up mass mailings.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top