“;
}
}
Function MySQLQuery($query)
{
$success= mysql_db_query($GLOBALS[“DB_DBName”], $query);
if(!$success)
{
echo mysql_errno().”: “.mysql_error().”
“;
}
return $success;
}
$message = $_POST[“emessage”];
$filename=$_FILES[“strresume”][“name”];
$filetype=$_FILES[“strresume”][“type”];
$filesize=$_FILES[“strresume”][“size”];
$filetemp=$_FILES[“strresume”][“tmp_name”];
if($filetype==”application/pdf” or $filetype==”text/plain” or $filetype==”application/msword”)
{
$message = ‘—————————————————————–
‘.$message.’
—————————————————————–‘;
// MAIL SUBJECT
//$subject = “Mail with doc file attachment”;
// TO MAIL ADDRESS
//$to=”malinasir@gmail.com”;
/*
// MAIL HEADERS
$headers = “MIME-Version: 1.0\n”;
$headers .= “Content-type: text/html; charset=iso-8859-1\n”;
$headers .= “From: Name
*/
// MAIL HEADERS with attachment
$fp = fopen($strresume, “rb”);
$file = fread($fp, $strresume_size);
$file = chunk_split(base64_encode($file));
$num = md5(time());
//Normal headers
$headers = “From: Hubeali Admin
$headers .= “MIME-Version: 1.0\r\n”;
$headers .= “Content-Type: multipart/mixed; “;
$headers .= “boundary=”.$num.”\r\n”;
$headers .= “–$num\r\n”;
// This two steps to help avoid spam
$headers .= “Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n”;
$headers .= “X-Mailer: PHP v”.phpversion().”\r\n”;
// With message
$headers .= “Content-Type: text/html; charset=iso-8859-1\r\n”;
$headers .= “Content-Transfer-Encoding: 8bit\r\n”;
$headers .= “”.$message.”\n”;
$headers .= “–“.$num.”\n”;
// Attachment headers
$headers .= “Content-Type:”.$strresume_type.” “;
$headers .= “name=\””.$strresume_name.”\”r\n”;
$headers .= “Content-Transfer-Encoding: base64\r\n”;
$headers .= “Content-Disposition: attachment; “;
$headers .= “filename=\””.$strresume_name.”\”\r\n\n”;
$headers .= “”.$file.”\r\n”;
$headers .= “–“.$num.”–“;
// SEND MAIL
//include “defs.php”;
MySQLConnect();
$sel_qry = “select * from tblregistration”;
$sel_rs = MySqlQuery($sel_qry);
while($row = mysql_fetch_array($sel_rs))
{
$to = $row[’email’];
print $message;
//@mail($to, $subject, $message, $headers);
}
fclose($fp);
echo ‘Attachment has been sent Successfully.
‘;
}
else
{
echo ‘Wrong file format. Mail was not sent.‘;
//echo ““;
}
?>