General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 5th, 2003, 12:44 PM
Decoy Decoy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 28 Decoy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
sending multiple emails/data repeating itself

I have a simple db table named 'mail' which has a mailid, email, fname, and lname. I am running a query to pull the mailid and email and then am looping through the result set mailing each one. It sends the emails fine but the link in the body of the message that allows the recipient to remove themselves from the database is repeating itself in every message. For example, there are 4 people in the db. Every mail sent out contains 4 messages saying 'You have received this message because you have visited our site....blah, blah.' and each one is pointing to a differnt mailid.

I've stripped out the relevant code below.
PHP Code:
 $sender_email 'Karen\'s Site';
$header "From: \"".$sender_email."\" <".$sender_email.">\n"
$header .= "Reply-To: ".$sender_email."\n"
$header .= "MIME-Version: 1.0\n"
$header .= "Content-Type: text/html; charset=iso-8859-1\n"
$header .= "X-Priority: 3\n";
     
$sql "select mailid, email from mail";      
$res mysql_query($sql);

while(
$myrow mysql_fetch_array($res))
{
  
$email_addr $myrow['email'];
  
$id $myrow['mailid'];                
  
$message .= "<p><br><font face=arial size=1>You have received this message because you have visited our site\n";
  
$message .= "If you feel this is a mistake or would just like to unsubscribe,\n";        
  
$message .= "please <a href=\"http://mysite.com/unsub.php?mailid=" .$id"&action=delete_mail\">Click Here</a></font>\n";        
  
mail("$email_addr""$subject"$message$header);



Any suggestions?

Thanks

Reply With Quote
  #2  
Old October 5th, 2003, 08:26 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
You need to separate $message and the unsubscribe footer and reset the unsubscribe footer to "" at the beginning of each iteration of your loop. I would predict based on this code that the first user gets one footer, the second two, the third three, etc., because you just keep concatenating the footer to the end of $message, which you just concatenated another footer onto. Separate the two and pass $message . $footer to your mail function.

Reply With Quote
  #3  
Old October 5th, 2003, 10:13 PM
Decoy Decoy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 28 Decoy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hey dh,

After playing with it earlier I came up with exactly what you suggested. I appreciate the reply.

Thanks

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > sending multiple emails/data repeating itself


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT