function send_message($address, $message) { // global $return_msg; global $phpml; global $PHPML_LANG; $rc = false; if ($phpml['EmailSend']) { $mail = new MyMailer(); $mail->Subject = stripslashes('[' . $phpml['ListName'] . '] Mailing List'); $mail->Body = stripslashes($message); $mail->AddAddress($address); if (!$mail->Send()) { $_SESSION['return_msg'] = $PHPML_LANG["error_sending"] . " (" . $address . "): " . $mail->ErrorInfo; } else { $rc = true; } $mail->ClearAddresses(); } return $rc; }
function showAll() { $this->tpl->setMainTemplate("structure_mail.tpl"); $this->request->setModuleName('view_visits_rss'); $allSiteArchive = DataModel::getSites(); /** * Cache Lite */ $options = array('cacheDir' => DIR_CACHE_MAIL, 'lifeTime' => CACHE_MAIL_LIFETIME); $Cache_Lite = new Cache_Lite($options); $lang =& Lang::getInstance(); // case update to 2.2RC1 without executing global info if (!defined('INTERFACE_DEFAULT_LANG')) { define('INTERFACE_DEFAULT_LANG', 'en-utf-8.php'); } $lang->setNewLang(INTERFACE_DEFAULT_LANG); /** * Compute mails */ $o_config =& PmvConfig::getInstance(); foreach ($allSiteArchive as $infoSite) { /** * php Mailer */ $mail = new MyMailer(); $mail->IsHTML(true); $imgUrl = INCLUDE_PATH . "/themes/default/images/phpmv.png"; $mail->AddEmbeddedImage($imgUrl, "my-attach", $GLOBALS['lang']['logo_description'], "base64", "image/png"); $uniqCacheId = md5(serialize($infoSite) . date("Y-m-d")) . '.mail'; // Test if thereis a valide cache for this id if (true) { $o_mod = new ViewVisitsRss($infoSite); $this->request->date = getDateFromTimestamp(time() - 86400); $o_mod->init($this->request); $dateLiteral = $o_mod->data->archive->getLiteralDate(); $body = '<html xml:lang="fr" > <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> </head> <body> '; $body .= $o_mod->showAll(true, true); $body .= '</body></html>'; $textBody = strip_tags($body); $subject = vsprintf($GLOBALS['lang']['rss_titre'], array($infoSite->getName(), $dateLiteral)); print "<br>Subject : {$subject}<hr>"; print "<br>Content : {$body}<hr>"; //$Cache_Lite->save($body); } $mail->Subject = $subject; $mail->Body = $body; $mail->AltBody = $textBody; $mail->CharSet = $GLOBALS['lang']['charset']; $user = new UserConfigDb(); $groups = $user->getGroups(); $users = array_merge(array(0 => array('email' => SU_EMAIL, 'alias' => 'phpMyVisites Administrator', 'send_mail' => SEND_MAIL == "yes" ? 1 : 0)), $user->getUserByGroup(1, $infoSite->getId()), $user->getUserByGroup(2, $infoSite->getId())); // we send all emails once $emailsToSend_infos = array('object' => $mail, 'to' => array()); // add recipients for the mail foreach ($users as $userInfo) { //print_r($userInfo); if (!empty($userInfo['email']) && $userInfo['send_mail'] == 1) { $emailsToSend_infos['to'][] = array($userInfo['email'], $userInfo['alias']); } } $emailsToSend[] = $emailsToSend_infos; } // send all emails foreach ($emailsToSend as $currMail) { $mail =& $currMail['object']; foreach ($currMail['to'] as $recipient) { $mail->AddAddress($recipient[0], $recipient[1]); if (!@$mail->Send()) { echo "<u><b>There was an error sending the message to " . $userInfo['email'] . "</u></b><br>"; } else { echo "<u><b>Message was sent successfully to " . $userInfo['email'] . "</u></b><br>"; } $mail->ClearAddresses(); } } }
if ($_POST['frmFormat'] == 'textonly') { $mail->Body = $textmsg; } else { $mail->MsgHTML($message); $mail->AltBody = $textmsg; //"To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test } // now send it if (!$mail->Send()) { $x_errors++; echo $PHPML_LANG["error_sending"] . " to:" . $row['email'] . "<br /><br /><b>" . $mail->ErrorInfo . "<br /><br /></b>"; } else { $x_ok++; } if ($num > 1) { $mail->ClearAddresses(); $mail->ClearCCs(); $mail->ClearBCCs(); $mail->ClearReplyTos(); $mail->ClearAllRecipients(); $mail->ClearAttachments(); $mail->ClearCustomHeaders(); } $xi++; if (isset($phpml['progressmin'])) { $minProgressDisplay = $phpml['progressmin']; } else { $minProgressDisplay = 25; } if ($num > $minProgressDisplay) { $width += $width_per_iteration;
function send_message($address, $message) { global $phpml; require_once $phpml['PHPMailer_path'] . "/class.html2text.php"; // added by Steve Morton $rc = false; if ($phpml['EmailSend']) { if (!class_exists("MyMailer")) { _load_PHPMailer(); } // code added by Steve Morton $h2t =& new html2text($message); $textmsg = $h2t->get_text(); // end of code added by Steve Morton $mail = new MyMailer(); $mail->Subject = stripslashes('[' . $phpml['ListName'] . '] Mailing List'); // code added by Steve Morton $mail->AltBody = $textmsg; $mail->MsgHTML($message); // end of code added by Steve Morton $mail->AddAddress($address); if (!$mail->Send()) { $_SESSION['return_msg'] = "There has been a mail error sending to " . $address . ": " . $mail->ErrorInfo; } else { $rc = true; } $mail->ClearAddresses(); } return $rc; }