<html>
<head>
<title>InboX Mass Mailer</title>
</head>
<body>
<?php
if(!isset($_POST['submit'])) {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method='post'>
<table>
<tr>
<td>Desired Name:</td>
<td><input type='text' name='desiredname' /></td>
</tr>
<tr>
<td>Desired Email:</td>
<td><input type='text' name='desiredemail' /></td>
</tr>
<tr>
<td>Reply-to:</td>
<td><input type='text' name='replyto' /></td>
</tr>
<tr>
<td>Subject:</td>
<td><input type='text' name='subject' /></td>
</tr>
<tr>
<td>Recipients: (One Email per line)</td>
<td><textarea rows='5' cols='30' name='recipients'></textarea></td>
</tr>
<tr>
<td>Message: (Supports HTML)</td>
<td><textarea rows='10' cols='30' name='message'></textarea></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='submit' value='Send'></td>
</tr>
</table>
<?php
}
else {
$desiredname = (isset($_POST['desiredname']) ? $_POST['desiredname'] : FALSE);
$desiredemail = (isset($_POST['desiredemail']) ? $_POST['desiredemail'] : FALSE);
$replyto = (isset($_POST['replyto']) ? $_POST['replyto'] : FALSE);
$subject = (isset($_POST['subject']) ? $_POST['subject'] : FALSE);
$recipients = (isset($_POST['recipients']) ? $_POST['recipients'] : FALSE);
$message = (isset($_POST['message']) ? $_POST['message'] : FALSE);
if($desiredname == FALSE || $desiredemail == FALSE || $replyto == FALSE || $subject == FALSE || $recipients == FALSE || $message == FALSE) {
die('Something is wrong with the information you submitted.<br />Please check again.'); }
$allemails = preg_split("/\r\n|\n/", $recipients);
$allemailscount = count($allemails);
for($i = 0; $i <= $allemailscount; $i++) {
$to = $allemails[$i];
$message = "<html><body>" . $message . "</body></html>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: ' . $allemails[$i] . "\r\n";
$headers .= 'From: ' . $desiredname . ' <' . $desiredemail . '>' ."\r\n";
$headers .= 'Reply-to: ' . $replyto . "\r\n";
mail($to, $subject, $message, $headers);
}
}
?>