You can write it so that the user separates the emails by a comma (e.g., "you@yourdomain.com, me@mydomain.com, joe@doe.com" would send to all three of those addresses).
Accept the string, split it using a comma as a delimiter and write a loop to iterate through each email.
PHP Code:
<?php
/**
* @author : wlt-php
* @copyright: 2012
*/
//mail(to ,title, msg, headers);
$emails = explode(",", $_POST['youremail']);
$title = $_POST['title'];
$impor = $_POST['impor'];
$tmsg = $_POST['textmsg'];
if(isset($_POST['do']) && $_POST['do'] == 'send'){
if(count($emails) == 0){
echo "Please type E-mail";
}elseif(empty($tmsg)){
echo "Type Your Message ..!";
}else{
$sub = $title;
$msg = $tmsg;
$headers ="MIMI-Version: 1.0 \r\n";
$headers .="From: $E-MaiL $title \r\n";
$headers .="Content-Type: text/html; charset=utf-8 \r\n";
$headers .="X-priority: 3 \r\n";
foreach($emails as $e) {
$e = str_replace(" ", "", $e);
mail($e ,$title, $msg, $headers);
}
die("Message Sent");
}
}
?>
<form action="sendmail.php" method="POST" >
<table width="60" border="4" align="center">
<tr>
<td>E-mail</td>
<td><input type="text" name="youremail" size="40" /></td>
</tr>
<tr>
<td>Subject (separate by comma)</td>
<td><input type="text" name="title" size="40" /></td>
</tr>
<tr>
<td>Message Box</td>
<td><textarea name="textmsg" rows="20" cols="30"></textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Send" /></td>
</tr>
</table>
<input type="hidden" name="do" value="send" />
</form>
Bookmarks