E-mail Sending Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
maskme
Forum Newbie
Posts: 6
Joined: Sun Jul 28, 2002 9:27 am

E-mail Sending Problem

Post by maskme »

Dear All

I'm retrieving all the emails from xyz database, n sending it out. But the problem is tht to whomsoever gets the email, gets the matter of all the emails sent to others.

for eg a person recieving an email will get like this:

----------------------
Dear XYZ

How are you?

Dear ZYX

How are you?

& so on till all the emails from the database
------------------------

It is not going individually

Wat cud the problem be in the below code?

Code: Select all

while( $srow = mysql_fetch_array( $sresult ) )
    {
     $fn = $srowї'FULLNAME'];
     $id = $srowї'ID_NO'];
     $Fromname = "School";
     $Fromaddress = "school@desgins.com";
     $body = $body.''."Dear $fn ($id)\n\n" .$comm;
     if ($srowї'EMAIL'] != "")
      {
       $cnt = $cnt + 1;    
       $sendto = $srowї'EMAIL'];
       mail($sendto, $subject, $body, "From: ".$Fromname." <".$Fromaddress.">");
     &#125;
    &#125;
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

It's because you're just adding the contents of each message to the $body variable:

Code: Select all

$body = $body.''."Dear $fn ($id)\n\n" .$comm;
You need to clear the message body's variable each time otherwise it will just end up full of the messages sent to each person and that's what'll be sent in the emails.

Mac
Post Reply