コード例 #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 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);
 }
コード例 #3
0
ファイル: newsletters.php プロジェクト: Doluci/tomatocart
 function sendEmails()
 {
     global $toC_Json, $osC_Database, $osC_Language;
     $email = osC_Newsletters_Admin::getData($_REQUEST['newsletters_id']);
     $audience = array();
     if (!empty($_REQUEST['newsletters_id'])) {
         $Qcustomers = $osC_Database->query('select c.customers_id, 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 nl.email_address is  null');
         $Qcustomers->bindTable(':table_customers', TABLE_CUSTOMERS);
         $Qcustomers->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
         $Qcustomers->bindInt(':newsletters_id', $_REQUEST['newsletters_id']);
         $customers = explode(',', $_REQUEST['batch']);
         if (!in_array('***', $customers)) {
             $Qcustomers->appendQuery(' and c.customers_id in (":customers_id") ');
             $Qcustomers->bindRaw(':customers_id', implode('", "', array_unique(array_filter(array_slice($customers, 0, MAX_DISPLAY_SEARCH_RESULTS), 'is_numeric'))));
         }
         $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, $email['title']);
             $osC_Mail->setBodyHTML($email['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', $_REQUEST['newsletters_id']);
                 $Qlog->bindValue(':email_address', $value['email_address']);
                 $Qlog->execute();
             }
         }
         $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'));
     echo $toC_Json->encode($response);
 }
コード例 #4
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();
}
コード例 #5
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;
 }