Hallo,

Bij onderstaand mailscript kan er maar naar 1 adres tegelijk worden gemaild. Nu heb ik 2 invoervakken gemaakt met "emailadres geadresseerde". Er wordt echter alleen een email gestuurd naar het emailadres in het 2 invoervak.
Wat gaat er fout:

Code:
<?php
session_start();

if (isset($_POST['address']) && isset($_POST['subject']) && isset($_POST['body'])) {
if ($_POST['address'] == "" || $_POST['body'] == "") {
print_error();
print_form();
} else {
mail($_POST['address'], $_POST['subject'], $_POST['body'], 'From:[email protected]);
print_sent();
}
} else {
print_form();
}

function print_form() {


?>
<html>
<body bgcolor=cccccc>
<table align=center bgColor=98cb00 width=100% height=100%>
<form action="email.php" method="POST">
<table align=center bgColor=98cb00>
<tr bgColor=98cb00>
<td><B>Emailadres ontvanger:</B></td>
<td><input type="text" size=60 name="address"></td></tr>
<tr bgColor=98cb00>
<td><B>Emailadres ontvanger:</B></td>
<td><input type="text" size=60 name="address"></td></tr>
<tr>
<td></b>Onderwerp:</B></td>
<td><input type="text" size=60 name="subject"></td></tr>
<tr><td colspan=2><textarea cols=80 rows=25 name="body" class="text"></textarea></td></tr>
<tr><td>&nbsp;</td><td><input type="submit" value="Zend de email"></td></tr>
</form>
</table>
<?


function print_error() {
?>
<table width=100%>
<tr bgColor=98cb00><td>Je hebt iets overgeslagen!</td></tr>
</table>
<?
}
}


function print_sent() {
?>

<tr bgColor=98cb00><td>Bericht succesvol verzonden!


?>
</table>
<?
}

?>
Lees dit eens goed door.
[edit]Hier is een voorbeeld:[/edit]

<?php
// multiple recipients
$to  = '[email protected]' . ', '; // note the comma
$to .= '[email protected]';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<html>
<head>
  <title>Birthday Reminders for August</title>
</head>
<body>
  <p>Here are the birthdays upcoming in August!</p>
  <table>
   <tr>
     <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
   </tr>
   <tr>
     <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
   </tr>
   <tr>
     <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
   </tr>
  </table>
</body>
</html>
';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n";
$headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";
$headers .= 'Bcc: [email protected]' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
?> 
Het zou handig zijn als ik dat ook in een invoervak zelf kan invoeren, in plaats van in de code zelf.

Reageren