foreach ($rows as $row) {
unset($mailer);
$mailer =& JFactory::getMailer();
$mailer->setSubject($subject);
$mailer->setSender(array($replyto, $mosConfig_fromname));
$body = str_replace( "[NAME]", $name, $html_message);
$body = str_replace( "[EMAIL]", $row->email, $body);
$mailer->setBody($body);
$mailer->addRecipient($row->email);
$mailer->IsHTML(true);
// Send the Mail
$rs = $mailer->Send();
if ( JError::isError($rs) ) {
$i++; // Added to prevent double mailings when errors occur
$errors++;
} else {
$i++;
}
}
$msg = '';
if( $errors > 0) {
$msg = $mymail->ErrorInfo." => $errors Errors";
}