コード例 #1
0
ファイル: email_template.php プロジェクト: Doluci/tomatocart
 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();
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 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
ファイル: general.php プロジェクト: sajad1441/TomatoShop-v1
/**
 * 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();
}
コード例 #6
0
 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();
 }
コード例 #7
0
 function sendSystemMail($data)
 {
     global $osC_Session;
     $mailer = new osC_Mail();
     $mailer->setFrom($this->getAccountName(), $this->getAccountEmail());
     foreach ($data['to'] as $to) {
         $mailer->addTo($to['name'], $to['email']);
     }
     if ($data['cc'] != null) {
         foreach ($data['cc'] as $cc) {
             $mailer->AddCC($cc['name'], $cc['email']);
         }
     }
     if ($data['bcc'] != null) {
         foreach ($data['bcc'] as $bcc) {
             $mailer->AddBCC($bcc['name'], $bcc['email']);
         }
     }
     $mailer->setSubject($data['subject']);
     if ($data['content_type'] == 'html') {
         $mailer->setBodyHTML($data['body']);
     } elseif ($data['content_type'] == 'text') {
         $mailer->setBodyPlain($data['body']);
     }
     $path = DIR_FS_CACHE_ADMIN . 'emails/attachments/' . $osC_Session->getID();
     $directory = new osC_DirectoryListing($path);
     if ($directory->getSize() > 0) {
         foreach ($directory->getFiles() as $file) {
             $mailer->AddAttachment($path . '/' . $file['name']);
         }
     }
     if ($mailer->Send()) {
         $data['messages_flag'] = EMAIL_MESSAGE_SENT_ITEM;
         return $this->saveSentMessage($data);
     }
     return false;
 }
コード例 #8
0
ファイル: email.php プロジェクト: Doluci/tomatocart
 function sendMail()
 {
     global $toC_Json, $osC_Language;
     $to = array();
     $emails = explode(';', $_REQUEST['to']);
     foreach ($emails as $email) {
         if (!empty($email)) {
             $to[] = osC_Mail::parseEmail($email);
         }
     }
     $cc = array();
     if (isset($_REQUEST['cc']) && !empty($_REQUEST['cc'])) {
         $emails = explode(';', $_REQUEST['cc']);
         foreach ($emails as $email) {
             if (!empty($email)) {
                 $cc[] = osC_Mail::parseEmail($email);
             }
         }
     }
     $bcc = array();
     if (isset($_REQUEST['bcc']) && !empty($_REQUEST['bcc'])) {
         $emails = explode(';', $_REQUEST['bcc']);
         foreach ($emails as $email) {
             if (!empty($email)) {
                 $bcc[] = osC_Mail::parseEmail($email);
             }
         }
     }
     $attachments = array();
     if (isset($_REQUEST['attachments']) && !empty($_REQUEST['attachments'])) {
         $attachments = explode(';', $_REQUEST['attachments']);
     }
     $toC_Email_Account = new toC_Email_Account($_REQUEST['accounts_id']);
     $data = array('accounts_id' => $toC_Email_Account->getAccountId(), 'id' => $_REQUEST['id'], 'to' => $to, 'cc' => $cc, 'bcc' => $bcc, 'from' => $toC_Email_Account->getAccountName(), 'sender' => $toC_Email_Account->getAccountEmail(), 'subject' => $_REQUEST['subject'], 'reply_to' => $toC_Email_Account->getAccountEmail(), 'full_from' => $toC_Email_Account->getAccountName() . ' <' . $toC_Email_Account->getAccountEmail() . '>', 'body' => $_REQUEST['body'], 'priority' => $_REQUEST['priority'], 'content_type' => $_REQUEST['content_type'], 'notification' => $_REQUEST['notification'], 'udate' => time(), 'date' => date('m/d/Y H:i:s'), 'fetch_timestamp' => time(), 'messages_flag' => EMAIL_MESSAGE_DRAFT, 'attachments' => $attachments);
     if ($toC_Email_Account->sendMail($data)) {
         $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);
 }