Jump to content

Emailing Multiple Recipients Problem


Gunther

Recommended Posts

Hi

 

I am having a problem with a form I have created.  Its a simple enough form where I want people to select a particular number of people to send the message to from a list.  The problem I am having is that even though I select a number of people in the list the form only sends one email to the last person selected.  Just wondering could some of you guys a quick look to see whats up.  Cheers!

 

<?php

$FriendName = $_POST['FriendName'];
$FriendEmail = $_POST['FriendEmail'];
$Name = $_POST['Name'];
$Email = $_POST['Email'];
$emailtext = $_POST['emailtext'];
$string = $_SERVER['QUERY_STRING'];

?>
<html><head>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
<link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
body {
background-color: #FFFFFF;
}
-->
</style>
</head>
<body>
<?php
if (!$FriendEmail) {
?>
<br>
<form name="form1" action="" method="POST">
<div align="center">
<table width="647" border="0" cellspacing="0" cellpadding="3">
  <tr> 
    <td width="194" align="right" valign="top"><font face="Verdana" size="2"><b>You Name:</b></font></td>
    <td width="441"> 
      <font face="Verdana"><span id="sprytextfield1">
      <label>
      <input type="text" name="Name" id="Name">
      </label>
      <span class="textfieldRequiredMsg">A value is required.</span></span><font size="2"> </font></font>    </td>
    </tr>
  <tr>
    <td align="right" valign="top"><font face="Verdana" size="2"><b>You Email Address:</b></font></td>
    <td><span id="sprytextfield2">
    <label>
    <input type="text" name="Email" id="Email">
    </label>
    <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
    </tr>
  <tr> 
    <td align="right" valign="top"><font face="Verdana" size="2"><b>Politicians you wish to contact:</b></font></td>
    <td> 
      <font face="Verdana"><font size="2"> </font>		</font>    <span id="spryselect1">
      <label>
      <select name="FriendEmail" size="5" multiple id="FriendEmail">
        <option value="[email protected]">Cntact 1</option>
        <option value="[email protected]">Contact 2</option>
        <option value="[email protected]">Contact 3</option>
          </select>
      </label>
      <span class="selectRequiredMsg">Please select an item.</span></span><br></td>
    </tr>
  <tr> 
    <td align="right" valign="top"><font face="Verdana" size="2"><b>Message:</b></font></td>
    <td> 
      <font face="Verdana">
<textarea name="emailtext" cols="40" rows="10" style="font-family: Trebuchet MS; font-size: 10pt">Message text Here!</textarea>
<font size="2"> </font></font>    <br>
      <span class="style1">The message above is a default message which will be sent on your behalf. Please feel free to delete this text and replace it with your own feelings on the issue.</span></td>
  </tr>
  <tr> 
    <td align="right"> </td>
    <td> 
      <font face="Verdana"> 
      <input type="submit" value="Send" name="Submit"><font size="2"> </font>		</font>    </td>
    </tr>
</table>
</div>
</form>



<?php
}
else {
if ($FriendEmail) { mail( $FriendEmail, "Message from $Name", "".$emailtext ."\n\nSincerely $Name", "From: $Email"); 
                    
  }


echo "<center><br><br><font face=Verdana size=2>Thank you <font color=red>$Name</font>. The email has been sent. <br><br>";
}

echo $FriendEmail;
?>
<p> </p>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "email");
//-->
</script>
</body>
</html>


Link to comment
https://forums.phpfreaks.com/topic/166248-emailing-multiple-recipients-problem/
Share on other sites

By the way I had to create a new account using the name 'New Account' as I couldnt remember by password and for some reason it took hours for the password reminder to arrive. 

 

Did anyone look at the code above to see why its only emailing one person?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.