I want to send an email where the reactants are
the user enters their name ($name)
enters their email ($email)
the people they want to send to (seperated by a single comma): ($recipient)
their personal message ($message)

<?
$subject = "$name recommends you to visit mysite"; 
$message = "$name recommends you to visit my site blablabla


---This is an automated response, please do not reply!---"; 
$display = explode (",", $recipient);
$streturn = array($display);
for ($i=0; $i<$display; $i++) {
$streturn[$i];
}
return $streturn;
$mailheaders = "From: $email from * <$email> \n";
$mailheaders .= "Reply-To: $email\n";
$to = $streturn;

mail($to, $subject, $message, $mailheaders); 

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="style.css" type="text/css">
</head>

<body>
<table width="75%" border="0" align="center">
  <tr>
    <td><div align="center">
        <p>Thank you for submitting e-mail using <strong><em><font color="#FF0000" face="Georgia, Times New Roman, Times, serif">e</font></em></strong>-oped.com</p>
        <p>Your message has been submitted to your friend(s). <br>
          <a href="javascript:history.go(-2);">Go back to where you were.</a></p>
        <p><? echo"$to"; ?></p><div align="center">
        These are the following people that will recieve your 
          e-mail in a few minutes:</div><div align="left"><br>
          <? echo "$display[0]"; ?><br>
          <? echo "$display[1]"; ?> <br>
          <? echo "$display[2]"; ?> <br>
          <? echo "$display[3]"; ?> <br>
          <? echo "$display[4]"; ?> <br>
          <? echo "$display[5]"; ?> <br> </div>
      </div></td>
  </tr>
</table>
</body>
</html>

    First, what's the problem? Where are you stuck?

    Second, why are you doing all this?

    $display = explode (",", $recipient); 
    $streturn = array($display);
    for ($i=0; $i<$display; $i++) {
    $streturn[$i];
    }
    return $streturn;
    to = $streturn;

      I have a form! Where a person wants to email an article to his friends, sooooo... i put a text box called "recipients", where he will type in as many emails as he can with a comma (ex: myfriend@bla.com,mycousin@mysite.com,mybrother@uranus.com) and they seperate with commas, so that my script will get rid of the comma and send the same email ($message) to everyone of the people in the "recipients" box ($recipients)

      $display = explode (",", $recipient);
      $streturn = array($display);
      for ($i=0; $i<$display; $i++) {
      $streturn[$i];
      }
      return $streturn;
      $mailheaders = "From: $email from * <$email> \n";
      $mailheaders .= "Reply-To: $email\n";
      $to = $streturn;
      
      mail($to, $subject, $message, $mailheaders); 
       

      and it doesnt send anyone any emails

        if i'm not mistaken, you don't need to set $streturn at all, you can just use display - explode sets it as an array, so your clear on that.

        now, it's not e-mailing anything becuase your $to isn't coming up with anything. try this...

        $display = explode (",", $recipient);
        
        for ($i=0; $i<$display; $i++) {	
        //mail headers here 
        mail($display[$i], $subject, $message, $mailheaders); 
        }
        
         

          When sending mail to multiple people the $to should be comma delimited. The method dv6cougar showed should work, it just sends the emails one at a time. If you want to send them all at the same time, leave the field as it is. Of course, you'll want to check that they filled it in right

            Originally posted by LordShryku
            When sending mail to multiple people the $to should be comma delimited. The method dv6cougar showed should work, it just sends the emails one at a time. If you want to send them all at the same time, leave the field as it is. Of course, you'll want to check that they filled it in right

            yeah, I would prefer to do it 1 at a time however, because then the "to" field in the e-mail doesn't have alot of e-mails listed, this get's very annoying to users and if a "mass" mailer get's ahold of it, your responsible for spam e-mail and I know I hate spam 🙂

              True, but if you're allowing them to put a million emails in there, that's your fault. The best thing to do is to split it out into seperate fields, maybe 3 or 4, and have them input one email per line. Some users will have trouble with the concept of comma delimiting, and screw up the form anyway.

                Originally posted by LordShryku
                True, but if you're allowing them to put a million emails in there, that's your fault. The best thing to do is to split it out into seperate fields, maybe 3 or 4, and have them input one email per line. Some users will have trouble with the concept of comma delimiting, and screw up the form anyway.

                yeah, definitely. I have such a feature on one of my sites (tunercarz.com) to E-mail a link to a Car Profile and I just let them do one at a time.

                  thx for your help
                  IT WORKED...

                  but i need more:

                  i updated my code so that it will create a log file so we get some statistics about how many people use this part of the page!!

                  So i made this:

                  
                  $errorlogname = "/logfiles/emailfriends.txt";
                  $errorlog = @fopen($errorlogname, "a+") or die("Error A5: Could not log in to master server Please try again later, the webmaster is probably doing maintanence on this part of the website. Sorry for the inconvinience.");
                  $curdate = date("l, F j, Y");
                  $i = 0;
                  $n = $i++;
                  $userip = $REMOTE_ADDR;
                  $time = date("h:i a");
                  $newlog = "Log #".$n.": ".$curdate.": Email sent from $email to $recipient: by ip: $userip @ $time";
                  @fwrite($errorlog, $newlog) or die("Error A4: Could not write into master log file Please try again later, the webmaster is probably doing maintanence on this part of the website. Sorry for the inconvinience.");
                  fclose($errorlog);
                  
                  

                  when i do it i get the die error (A5) why?

                    Pull the @ off of the front of it and let it tell you why. Doesn't hurt to put an error_report(E_ALL) at the top of the scripts when you're making them too, so all errors are reported.

                      Warning: fopen(/logfiles/emailfriends.txt): failed to open stream: No such file or directory in /home/designs/public_html/e-oped/emailit.php on line 27

                        and when i remove "/logfiles/"

                        it does
                        Warning: fopen(emailfriends.txt): failed to open stream: Permission denied in /home/designs/public_html/e-oped/emailit.php on line 27

                        but i want a frickin folder....

                          Okay, so make the folder using [man]mkdir[/man]

                            Write a Reply...