Skip to main content
Inspiring
May 1, 2012
Answered

email a form to two recipient in php - only sends to one?

  • May 1, 2012
  • 1 reply
  • 612 views

have the a form that when it is sent get directed to two recipients how it is only getting through to one, what am i doing wrong please??

mysql_select_db($database_hostprop, $hostprop);

  $Result1 = mysql_query($insertSQL, $hostprop) or die(mysql_error());

 

            // Email Admin

          $to = "name@email.com" . ", " ;

          $to = "name2@email.com";

          // Email Tenant

          $subject = "New";

          $message = "

          <html>

                    <head>

                              <title>New </title>

                    </head>

                    <body>

  <tr>

    <td>Other Comments</td>

    <td>".GetSQLValueString($_POST['otherComments'], "text")."</td>

  </tr>

</body>

          </html>

          ";

 

          // Always set content-type when sending HTML email

          $headers = "MIME-Version: 1.0" . "\r\n";

          $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

          $headers .= 'From:www.website.com <email@domain.com>' . "\r\n";

 

          $send = mail($to,$subject,$message,$headers);

thanks in advance

This topic has been closed for replies.
Correct answer Jonathan_Fortis

ok  works

changed it to

$to = "name@email.com,name2@email.com" ;

thanks

1 reply

Participating Frequently
May 2, 2012

Look at your variable assignment operation. You are assigning $to to the first address, then reassigning it to the second. You'd need to concatenate, right?

Jonathan_FortisAuthorCorrect answer
Inspiring
May 2, 2012

ok  works

changed it to

$to = "name@email.com,name2@email.com" ;

thanks