示例#1
0
 function sendEmail()
 {
     if ($this->_status == '1') {
         foreach ($this->_recipients as $recipient) {
             if (SEND_EMAILS == '-1') {
                 return false;
             }
             $osC_Mail = new osC_Mail($recipient['name'], $recipient['email'], STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, $this->_title);
             $osC_Mail->setBodyHTML($this->_email_text);
             if ($this->hasAttachment()) {
                 foreach ($this->_attachments as $attachment) {
                     $osC_Mail->addAttachment($attachment[0], $attachment[1]);
                 }
             }
             $osC_Mail->send();
         }
     }
 }
示例#2
0
 function sendEmail()
 {
     global $osC_Database, $osC_Language, $osC_Template;
     $max_execution_time = 0.8 * (int) ini_get('max_execution_time');
     $time_start = explode(' ', PAGE_PARSE_START_TIME);
     $Qrecipients = $osC_Database->query('select c.customers_firstname, c.customers_lastname, c.customers_email_address from :table_customers c left join :table_newsletters_log nl on (c.customers_email_address = nl.email_address and nl.newsletters_id = :newsletters_id) where c.customers_newsletter = 1 and nl.email_address is null');
     $Qrecipients->bindTable(':table_customers', TABLE_CUSTOMERS);
     $Qrecipients->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
     $Qrecipients->bindInt(':newsletters_id', $this->_newsletter_id);
     $Qrecipients->execute();
     if ($Qrecipients->numberOfRows() > 0) {
         $osC_Mail = new osC_Mail(null, null, null, EMAIL_FROM, $this->_newsletter_title);
         $osC_Mail->setBodyPlain($this->_newsletter_content);
         while ($Qrecipients->next()) {
             $osC_Mail->clearTo();
             $osC_Mail->addTo($Qrecipients->value('customers_firstname') . ' ' . $Qrecipients->value('customers_lastname'), $Qrecipients->value('customers_email_address'));
             $osC_Mail->send();
             $Qlog = $osC_Database->query('insert into :table_newsletters_log (newsletters_id, email_address, date_sent) values (:newsletters_id, :email_address, now())');
             $Qlog->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
             $Qlog->bindInt(':newsletters_id', $this->_newsletter_id);
             $Qlog->bindValue(':email_address', $Qrecipients->value('customers_email_address'));
             $Qlog->execute();
             $time_end = explode(' ', microtime());
             $timer_total = number_format($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0]), 3);
             if ($timer_total > $max_execution_time) {
                 echo '<p><font color="#38BB68"><b>' . $osC_Language->get('sending_refreshing_page') . '</b></font></p>' . '<form name="execute" action="' . osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule() . '&page=' . $_GET['page'] . '&nID=' . $this->_newsletter_id . '&action=send') . '" method="post">' . '<p>' . osc_draw_hidden_field('subaction', 'execute') . '</p>' . '</form>' . '<script language="javascript">' . 'var counter = 3;' . 'function counter() {' . '  count--;' . '  if (count > 0) {' . '    Id = window.setTimeout("counter()", 1000);' . '  } else {' . '    document.execute.submit();' . '  }' . '}' . '</script>';
                 exit;
             }
         }
         $Qrecipients->freeResult();
     }
     $Qupdate = $osC_Database->query('update :table_newsletters set date_sent = now(), status = 1 where newsletters_id = :newsletters_id');
     $Qupdate->bindTable(':table_newsletters', TABLE_NEWSLETTERS);
     $Qupdate->bindInt(':newsletters_id', $this->_newsletter_id);
     $Qupdate->execute();
 }
 function sendNewsletters()
 {
     global $toC_Json, $osC_Database, $osC_Language;
     $time_start = explode(' ', PAGE_PARSE_START_TIME);
     $max_execution_time = 0.8 * (int) ini_get('max_execution_time');
     $email = osC_Newsletters_Admin::getData($_REQUEST['newsletters_id']);
     $error = false;
     $Qrecipients = $osC_Database->query('select c.customers_firstname, c.customers_lastname, c.customers_email_address from :table_customers c left join :table_newsletters_log nl on (c.customers_email_address = nl.email_address and nl.newsletters_id = :newsletters_id) where c.customers_newsletter = 1 and nl.email_address is null');
     $Qrecipients->bindTable(':table_customers', TABLE_CUSTOMERS);
     $Qrecipients->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
     $Qrecipients->bindInt(':newsletters_id', $_REQUEST['newsletters_id']);
     $Qrecipients->execute();
     if ($Qrecipients->numberOfRows() > 0) {
         $osC_Mail = new osC_Mail(null, null, null, EMAIL_FROM, $email['title']);
         $osC_Mail->setBodyHTML($email['content']);
         while ($Qrecipients->next()) {
             $osC_Mail->clearTo();
             $osC_Mail->addTo($Qrecipients->value('customers_firstname') . ' ' . $Qrecipients->value('customers_lastname'), $Qrecipients->value('customers_email_address'));
             $osC_Mail->send();
             $Qlog = $osC_Database->query('insert into :table_newsletters_log (newsletters_id, email_address, date_sent) values (:newsletters_id, :email_address, now())');
             $Qlog->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
             $Qlog->bindInt(':newsletters_id', $_REQUEST['newsletters_id']);
             $Qlog->bindValue(':email_address', $Qrecipients->value('customers_email_address'));
             $Qlog->execute();
             $time_end = explode(' ', microtime());
             $timer_total = number_format($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0]), 3);
             if ($timer_total > $max_execution_time) {
                 $error === true;
             }
         }
         $Qrecipients->freeResult();
     }
     if ($error === false) {
         $Qupdate = $osC_Database->query('update :table_newsletters set date_sent = now(), status = 1 where newsletters_id = :newsletters_id');
         $Qupdate->bindTable(':table_newsletters', TABLE_NEWSLETTERS);
         $Qupdate->bindInt(':newsletters_id', $_REQUEST['newsletters_id']);
         $Qupdate->execute();
         $response = array('success' => true, 'feedback' => $osC_Language->get('ms_success_action_performed'));
     } else {
         $response = array('success' => false, 'feedback' => $osC_Language->get('ms_error_action_not_performed'));
     }
     echo $toC_Json->encode($response);
 }
 function sendEmail()
 {
     global $osC_Database, $osC_Language;
     $max_execution_time = 0.8 * (int) ini_get('max_execution_time');
     $time_start = explode(' ', PAGE_PARSE_START_TIME);
     $audience = array();
     $customer = '';
     if (isset($_POST['customer']) && !empty($_POST['customer'])) {
         $customer = $_POST['customer'];
     } elseif (isset($_GET['customer']) && !empty($_GET['customer'])) {
         $customer = $_GET['customer'];
     }
     if (!empty($customer)) {
         $Qcustomers = $osC_Database->query('select customers_id, customers_firstname, customers_lastname, customers_email_address from :table_customers c left join :table_newsletters_log nl on (c.customers_email_address = nl.email_address and nl.newsletters_id = :newsletters_id) where nl.email_address is null');
         $Qcustomers->bindTable(':table_customers', TABLE_CUSTOMERS);
         $Qcustomers->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
         $Qcustomers->bindInt(':newsletters_id', $this->_newsletter_id);
         if (is_numeric($customer)) {
             $Qcustomers->appendQuery('and c.customers_id = :customers_id');
             $Qcustomers->bindInt(':customers_id', $customer);
         }
         $Qcustomers->execute();
         while ($Qcustomers->next()) {
             if (!isset($audience[$Qcustomers->valueInt('customers_id')])) {
                 $audience[$Qcustomers->valueInt('customers_id')] = array('firstname' => $Qcustomers->value('customers_firstname'), 'lastname' => $Qcustomers->value('customers_lastname'), 'email_address' => $Qcustomers->value('customers_email_address'));
             }
         }
         $Qcustomers->freeResult();
         if (sizeof($audience) > 0) {
             $osC_Mail = new osC_Mail(null, null, null, EMAIL_FROM, $this->_newsletter_title);
             $osC_Mail->setBodyPlain($this->_newsletter_content);
             foreach ($audience as $key => $value) {
                 $osC_Mail->clearTo();
                 $osC_Mail->addTo($value['firstname'] . ' ' . $value['lastname'], $value['email_address']);
                 $osC_Mail->send();
                 $Qlog = $osC_Database->query('insert into :table_newsletters_log (newsletters_id, email_address, date_sent) values (:newsletters_id, :email_address, now())');
                 $Qlog->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
                 $Qlog->bindInt(':newsletters_id', $this->_newsletter_id);
                 $Qlog->bindValue(':email_address', $value['email_address']);
                 $Qlog->execute();
                 $time_end = explode(' ', microtime());
                 $timer_total = number_format($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0]), 3);
                 if ($timer_total > $max_execution_time) {
                     echo '<p><font color="#38BB68"><b>' . $osC_Language->get('sending_refreshing_page') . '</b></font></p>' . '<META HTTP-EQUIV="refresh" content="2; URL=' . osc_href_link_admin(FILENAME_DEFAULT, 'newsletters&page=' . $_GET['page'] . '&nmID=' . $this->_newsletter_id . '&action=nmSendConfirm&customer=' . $customer) . '">';
                     exit;
                 }
             }
         }
         $Qupdate = $osC_Database->query('update :table_newsletters set date_sent = now(), status = 1 where newsletters_id = :newsletters_id');
         $Qupdate->bindTable(':table_newsletters', TABLE_NEWSLETTERS);
         $Qupdate->bindInt(':newsletters_id', $this->_newsletter_id);
         $Qupdate->execute();
     }
 }
示例#5
0
/**
 * Send an email
 *
 * @param string $to_name The name of the recipient
 * @param string $to_email_address The email address of the recipient
 * @param string $subject The subject of the email
 * @param string $body The body text of the email
 * @param string $from_name The name of the sender
 * @param string $from_email_address The email address of the sender
 * @access public
 */
function osc_email($to_name, $to_email_address, $subject, $body, $from_name, $from_email_address)
{
    if (SEND_EMAILS == '-1') {
        return false;
    }
    $osC_Mail = new osC_Mail($to_name, $to_email_address, $from_name, $from_email_address, $subject);
    $osC_Mail->setBodyHTML($body);
    $osC_Mail->send();
}
 function sendEmail()
 {
     global $osC_Database, $osC_Language;
     $max_execution_time = 0.8 * (int) ini_get('max_execution_time');
     $time_start = explode(' ', PAGE_PARSE_START_TIME);
     if (isset($_POST['chosen'])) {
         $chosen = $_POST['chosen'];
     } elseif (isset($_GET['chosen'])) {
         $chosen = $_GET['chosen'];
     } elseif (isset($_POST['global'])) {
         $global = $_POST['global'];
     } elseif (isset($_GET['global'])) {
         $global = $_GET['global'];
     }
     $chosen_get_string = '';
     if (isset($chosen) && !empty($chosen)) {
         foreach ($chosen as $id) {
             $chosen_get_string .= 'chosen[]=' . $id . '&';
         }
     }
     $audience = array();
     $Qcustomers = $osC_Database->query('select customers_id, customers_firstname, customers_lastname, customers_email_address from :table_customers where global_product_notifications = 1');
     $Qcustomers->bindTable(':table_customers', TABLE_CUSTOMERS);
     $Qcustomers->execute();
     while ($Qcustomers->next()) {
         if (!isset($audience[$Qcustomers->valueInt('customers_id')])) {
             $audience[$Qcustomers->valueInt('customers_id')] = array('firstname' => $Qcustomers->value('customers_firstname'), 'lastname' => $Qcustomers->value('customers_lastname'), 'email_address' => $Qcustomers->value('customers_email_address'));
         }
     }
     $Qcustomers = $osC_Database->query('select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from :table_products_notifications pn, :table_customers c left join :table_newsletters_log nl on (c.customers_email_address = nl.email_address and nl.newsletters_id = :newsletters_id) where pn.customers_id = c.customers_id and nl.email_address is null');
     $Qcustomers->bindTable(':table_products_notifications', TABLE_PRODUCTS_NOTIFICATIONS);
     $Qcustomers->bindTable(':table_customers', TABLE_CUSTOMERS);
     $Qcustomers->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
     $Qcustomers->bindInt(':newsletters_id', $this->_newsletter_id);
     if (isset($chosen) && !empty($chosen)) {
         $Qcustomers->appendQuery('and pn.products_id in (:products_id)');
         $Qcustomers->bindRaw(':products_id', implode(', ', $chosen));
     }
     $Qcustomers->execute();
     while ($Qcustomers->next()) {
         if (!isset($audience[$Qcustomers->valueInt('customers_id')])) {
             $audience[$Qcustomers->valueInt('customers_id')] = array('firstname' => $Qcustomers->value('customers_firstname'), 'lastname' => $Qcustomers->value('customers_lastname'), 'email_address' => $Qcustomers->value('customers_email_address'));
         }
     }
     if (sizeof($audience) > 0) {
         $osC_Mail = new osC_Mail(null, null, null, EMAIL_FROM, $this->_newsletter_title);
         $osC_Mail->setBodyPlain($this->_newsletter_content);
         foreach ($audience as $key => $value) {
             $osC_Mail->clearTo();
             $osC_Mail->addTo($value['firstname'] . ' ' . $value['lastname'], $value['email_address']);
             $osC_Mail->send();
             $Qlog = $osC_Database->query('insert into :table_newsletters_log (newsletters_id, email_address, date_sent) values (:newsletters_id, :email_address, now())');
             $Qlog->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
             $Qlog->bindInt(':newsletters_id', $this->_newsletter_id);
             $Qlog->bindValue(':email_address', $value['email_address']);
             $Qlog->execute();
             $time_end = explode(' ', microtime());
             $timer_total = number_format($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0]), 3);
             if ($timer_total > $max_execution_time) {
                 echo '<p><font color="#38BB68"><b>' . $osC_Language->get('sending_refreshing_page') . '</b></font></p>' . '<form name="execute" action="' . osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule() . '&page=' . $_GET['page'] . '&nID=' . $this->_newsletter_id . '&action=send&' . (isset($global) && $global == 'true' ? 'global=true' : $chosen_get_string)) . '" method="post">' . '<p>' . osc_draw_hidden_field('subaction', 'execute') . '</p>' . '</form>' . '<script language="javascript">' . 'var counter = 3;' . 'function counter() {' . '  count--;' . '  if (count > 0) {' . '    Id = window.setTimeout("counter()", 1000);' . '  } else {' . '    document.execute.submit();' . '  }' . '}' . '</script>';
                 exit;
             }
         }
     }
     $Qupdate = $osC_Database->query('update :table_newsletters set date_sent = now(), status = 1 where newsletters_id = :newsletters_id');
     $Qupdate->bindTable(':table_newsletters', TABLE_NEWSLETTERS);
     $Qupdate->bindInt(':newsletters_id', $this->_newsletter_id);
     $Qupdate->execute();
 }