File: /home/design11/kmedialab.com/htdocs/scripts/blast_mail.php
//
// William J Robblee 1/12/09 no warranties implied, free to use at own risk
//
// this script has to be in a directory named "scripts" just below your "htdocs" folder.
// my setup is like...
// site root (folder)
// config.php (file)
// -> htdocs (folder)
// index.html (file-example)
// -> scripts (folder)
// blast_mail.php (file)
//
//
// if you have any issue you can uncomment the code under "//dabug" and the script will write the $html variable
// content to a txt file on your server. you can also just change the variable written for further debugging if needed.
<?php
include '../../config.php';
// assign posted variables to local variables
$emails = $_REQUEST['emails'];
$subject= $_REQUEST['subject'];
$company= $_REQUEST['company'];
$html = $_REQUEST['html'];
$error = 0;
if( $emails == "" && (!strstr($emails,"@") || !strstr($emails,".")) )
{
$form_text = "<h4>Please enter at least one valid e-mail</h4><br />";
$error = 1;
}
if( $html == "" )
{
$form_text = "<h4>Please select a file to be the message of the email(s)</h4><br />";
$error = 1;
}
if( $error == 0 )
{
$from = $my_mail;
//# Common Headers
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: " . $company . " <" . $from . ">\n";
$headers .= "Reply-To: " . $company . " <" . $from . ">\n";
$headers .= "Return-Path: " . $company . " <" . $from . ">\n"; // these two to set reply address
$headers .= "Message-ID: <" . time() . "-" . $from . ">\n";
$headers .= "X-Mailer: PHP v" . phpversion(); // These two to help avoid spam-filters
ini_set("sendmail_from", $from);
$message = $html;
//dabug
//$handle = fopen("html.txt", "w");
//$message = fwrite($handle, $html);
//fclose($handle);
$form_text = "<h4>";
$email_arr = explode(",",$emails);
$form_text = $form_text . "Sent mail to...<br />";
while( list($key, $email) = each($email_arr) )
{
if( !ereg( "@", $email ) )
{
break;
}
mail($email, $subject, $message, $headers);
$form_text = $form_text . $email . "<br />";
}
$form_text = $form_text . "</h4>";
}
?>