Page 1 of 1

E-mail Sending Problem

Posted: Tue Oct 15, 2002 1:55 am
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;

Posted: Tue Oct 15, 2002 2:14 am
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