<?
class mailsending {
function sendingemail_phpmailer ($var_array,$template,$phpmailer,$FromName,$From,$to,$Subject)
{
if (!is_array($var_array))
{
echo "first variable should be an array. ITS NOT !";
exit;
}
require_once($phpmailer); // I changed this to require_once because i found that when i trued to look the class for multiple emails, the phpmailer class was recelared and hence caused issue. SO MADE THIS as require_once.
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "buzinessware.com"; // SMTP server
$mail->FromName = $FromName;
$mail->From = $From;
$mail->AddAddress($to);
$mail->Subject = $Subject;
$mail->IsHTML(true);
$filename = $template;
$fd = fopen ($filename, "r");
$mailcontent = fread ($fd, filesize ($filename));
foreach ($var_array as $key=>$value)
{
$mailcontent = str_replace("%%$value[0]%%", $value[1],$mailcontent );
}
$mailcontent = stripslashes($mailcontent);
fclose ($fd);
$mail->Body=$mailcontent;
if(!$mail->Send())
{
echo "There was an error sending the message";
exit;
}
}
}
?>