non tutto il codice è lunghissimo:
Codice PHP:
include("../phpmailer/phpunit.php");
require("../phpmailer/class.phpmailer.php");
error_reporting(E_ALL);
class phpmailerTest extends TestCase{
function phpmailerTest($name) {
/* must define this constructor */
$this->TestCase( $name );
}
function setUp() {
$this->Mail = new PHPMailer();
$this->Mail->Priority = 3;
//e molto altro
}
function BuildBody() {
$this->CheckChanges();
// Determine line endings for message
if($this->Mail->ContentType == "text/html" || strlen($this->Mail->AltBody) > 0) {
$eol = "<br/>";
$bullet = "<li>";
$bullet_start = "<ul>";
$bullet_end = "</ul>";
}
else {
$eol = "\n";
$bullet = " - ";
$bullet_start = "";
$bullet_end = "";
}
$ReportBody = "";
}
function SetAddress($sAddress, $sName = "", $sType = "to") {
switch($sType) {
case "to":
$this->Mail->AddAddress($sAddress, $sName);
break;
case "cc":
$this->Mail->AddCC($sAddress, $sName);
break;
case "bcc":
$this->Mail->AddBCC($sAddress, $sName);
break;
}
}
function test_Html() {
global $global_vars;
$this->Mail->IsHTML(true);
$this->Mail->Body .= "Body della newsletter";
$this->Mail->IsHTML(true);
$this->BuildBody();
include $_SERVER['DOCUMENT_ROOT']."/inc/connect.php";
$sqlMax= mysql_query("SELECT * FROM ".$DB.".TB_SALUTE WHERE id=".$_SESSION['id']."");
$rsMax = mysql_fetch_array($sqlMax) or die ("La query non è stata eseguita!" . mysql_error());
if (mysql_num_rows($sqlMax) == 1) {
$_SESSION['DtInizioValidita'] = $rsMax['DtInizioValidita'];
$_SESSION['struttura'] = $rsMax['struttura'];
$_SESSION['tipologia'] = $rsMax['tipologia'];
$_SESSION['descrizione']= $rsMax['descrizione'];
$_SESSION['PhImg'] = $rsMax['PhImg'];
$_SESSION['sito'] = $rsMax['sito'];
$_SESSION['email'] = $rsMax['email'];
$_SESSION['sconto'] = $rsMax['sconto'];
$sqlUser = mysql_query("SELECT * FROM ".$DB.".TB_UTENTI WHERE (Email<>'' OR Email<>NULL) AND newsletter=1");
if (mysql_num_rows($sqlUser) > 0) {
while ($rsUser = mysql_fetch_array($sqlUser)){
$_SESSION['IdUserEsterno'] = $rsUser['IdUserEsterno'];
$global_vars = array('mail_to' => $rsUser['Email'], 'mail_cc' => '','mail_bcc' => '');
$this->SetAddress($global_vars["mail_to"], $rsUser['Email']);
if(!$this->Mail->Send()){
//echo "ERROR";
}else{
//echo "Mail sent";
}
}
}
}
}
Questo è tutto.
Grazie mille.