function send($mailid, $admin_user, $emailAddr)
{
    if (!check_admin_user($admin_user)) {
        return false;
    }
    if (!($info = load_mail_info($mailid))) {
        echo "Cannot load list information for message {$mailid}";
        return false;
    }
    $subject = $info['subject'];
    //$CI->email->subject($subject);
    $listid = $info['listid'];
    $status = $info['status'];
    $sent = $info['sent'];
    $from_name = 'Trimart';
    $from_address = '*****@*****.**';
    //$CI->email->from($from_address,$from_name);
    $query = "select email from sub_lists where listid =" . $listid;
    $conn = db_connect();
    $result = $conn->query($query);
    if (!$result) {
        echo "No result";
        return false;
    } else {
        if ($result->num_rows == 0) {
            echo "There is nobody subscribed to list number {$listid}";
            return false;
        }
    }
    $mail = new PHPMailer();
    $mail->IsSMTP();
    // we are going to use SMTP
    $mail->SMTPAuth = true;
    // enabled SMTP authentication
    $mail->SMTPSecure = "ssl";
    // prefix for secure protocol to connect to the server
    $mail->Host = "smtp.gmail.com";
    //"";192.168.20.202    // setting GMail as our SMTP server
    $mail->Port = 465;
    //;8089                   // SMTP port to connect to GMail
    $mail->Username = "******";
    //"andre.campbell#mcalbds";  // user email address
    $mail->Password = "******";
    //"AC#220991";            // password in GMail
    // read in the text version of the newsletter
    $textfilename = APPPATH . "archive\\" . $listid . "\\" . $mailid . "\\text.txt";
    if (file_exists($textfilename)) {
        $tfp = fopen($textfilename, "r");
        $text = fread($tfp, filesize($textfilename));
        fclose($tfp);
    }
    // read in the HTML version of the newsletter
    $htmlfilename = APPPATH . "archive\\" . $listid . "\\" . $mailid . "\\index.html";
    if (file_exists($htmlfilename)) {
        $hfp = fopen($htmlfilename, "r");
        $html = fread($hfp, filesize($htmlfilename));
        fclose($hfp);
    }
    // get the list of images that relate to this message
    $query = "select path, mimetype from images where mailid = {$mailid}";
    $result = $conn->query($query);
    if (!$result) {
        echo '<p>Unable to get image list from database.</p>';
        return false;
    }
    $num = $result->num_rows;
    for ($i = 0; $i < $num; $i++) {
        //load each image from disk
        $row = $result->fetch_array();
        $imgfilename = APPPATH . "archive\\{$listid}\\{$mailid}\\" . $row[0];
        $imgtype = $row[1];
        // add each image to the object
        //$message->addHTMLImage($imgfilename, $imgtype, $imgfilename, true);
        $mail->AddEmbeddedImage($imgfilename);
        // some attached files
        //$mail->AddAttachment("images/phpmailer_mini.gif"); // as many as you want
    }
    // create message body
    //$body = $message->get();
    // create message headers
    $from = '"' . get_real_name($admin_user) . '" <' . $admin_user . '>';
    $hdrarray = array('From' => $from, 'Subject' => $subject);
    //$hdrs = $message->headers($hdrarray);
    if ($status == 'STORED') {
        $mail->isHTML(true);
        $mail->Subject = $subjectf;
        $mail->AddAddress($_POST['emailAddr'], $admin_user);
        $sent = FALSE;
        // send the HTML message to the administrator
        //$sender->send($admin_user, $hdrs, $body);
        if ($html) {
            $mail->Body = $html;
            if (!$mail->Send()) {
                echo "Error sending html version: " . $mail->ErrorInfo;
            }
        } else {
            $sent = TRUE;
        }
        if ($sent) {
            echo "Mail sent to {$admin_user} with email address " . $_POST['emailAddr'];
            // mark newsletter as tested
            $query = "update mail set status = 'TESTED' where mailid = {$mailid}";
            $result = $conn->query($query);
            echo '<p>Press send again to send mail to whole list.<center>';
            display_button('send', "&id={$mailid}");
            echo '</center></p>';
        }
        //$mail->ClearAddresses();
    } else {
        if ($status == 'TESTED') {
            $count = 0;
            $subscribers = get_subscribers($_GET['id']);
            $CI =& get_instance();
            $row = $CI->trimart->get_login_credentials($user, $password);
            // for each subscriber
            /*for($i = 0; $i < count($subscribers); $i++)
            	{
            		
            		$mail->AddAddress(subscriber[$i][0],$CI->trimart->get_real_name(subscriber[$i][0]));		
            	}*/
            $mail->AddAddress('jamalbutcher2@gmail', 'YOU');
            $mail->send();
            $query = "update mail set status = 'SENT', sent = now() \n              where mailid = {$mailid}";
            $result = $conn->query($query);
            echo "<p>A total of {$count} messages were sent.</p>";
        } else {
            if ($status == 'SENT') {
                echo '<p>This mail has already been sent.</p>';
            }
        }
    }
}
     }
     echo "</div>";
     break;
 case 't':
     if ($op == "subscriber_del_temp") {
         echo "<header><h3>" . translate("SUBSCRIBER_TEMP_TITLE") . "</h3></header>\n            <div class='module_content'>";
         $del_tmpaddr = empty($_POST['del_tmpaddr']) ? "" : $_POST['del_tmpaddr'];
         $deleted_temp = delete_subscriber($cnx, $row_config_globale['table_temp'], $list_id, $del_tmpaddr);
         if ($deleted_temp) {
             echo "<h4 class='alert_success'>" . translate("SUBSCRIBER_TEMP_DELETED") . "</h4>";
         } else {
             echo "<h4 class='alert_error'>" . translate("ERROR_DELETING_TEMP", "<i>{$del_tmpaddr}</i>") . "</h4>";
         }
         echo "</div>";
     }
     $tmp_subscribers = get_subscribers($cnx, $row_config_globale['table_temp'], $list_id);
     if (sizeof($tmp_subscribers)) {
         echo "<header><h3>" . translate("SUBSCRIBER_TEMP_TITLE") . "</h3></header>\n            <div class='module_content' align='center'>";
         echo "<h4 class='alert_info'>" . count($tmp_subscribers) . " adresses dans la base</h4><br>";
         echo "<form action='" . $_SERVER['PHP_SELF'] . "' method='post'>";
         echo "<input type='hidden' name='op' value='subscriber_del_temp'>";
         echo "<input type='hidden' name='action' value='manage'>";
         echo "<input type='hidden' name='page' value='subscribers'>";
         echo "<input type='hidden' name='t' value='t'>";
         echo "<input type='hidden' name='list_id' value='{$list_id}'>";
         echo "<input type='hidden' name='token' value='{$token}' />";
         echo "<select name='del_tmpaddr'>";
         foreach ($tmp_subscribers as $row) {
             echo "<option value='" . $row['email'] . "' >" . $row['email'] . "</option>";
         }
         echo "</select>";
Example #3
0
            send($_GET['id'], $_SESSION['admin_user'], $_POST['emailtest']);
            break;
        case 'view-mail':
            display_items('Unsent Mail', get_unsent_mail(get_user()), 'preview-html', 'preview-text', 'send');
            break;
        case 'subscribe':
            subscribe(get_user(), $_GET['id']);
            display_items('Subscribed Lists', get_subscribed_lists(get_user()), 'information', 'show-archive', 'subscribe');
            break;
        case 'unsubscribe':
            unsubscribe(get_user(), $_GET['id']);
            display_items('Subscribed Lists', get_subscribed_lists(get_user()), 'information', 'show-archive', 'unsubscribe');
            break;
        case 'modify':
            $list = address_book();
            $subscribers = get_subscribers($_GET['id']);
            ?>
		
		<ul class="nav nav-tabs">
			<li class="active"><a data-toggle="tab" href="#menu1">Subscribers</a></li>
			<li ><a onclick="changeAllClass('menu1','tab-pane fade');" data-toggle="tab" href="#home">Address Book</a></li>
		</ul>

		<div class="tab-content">
			<div id="menu1" class="tab-pane fade in active">
				<?php 
            for ($i = 0; $i < count($subscribers); $i++) {
                echo "<input type='checkbox' style='float:left;' value='" . $subscribers[$i][0] . "' name='cList[]'/><p>" . $subscribers[$i][1] . "   " . $subscribers[$i][0] . "</p>";
            }
            ?>
			</div>