示例#1
0
 public static function resendEmailFromLog($id)
 {
     $resendEmail = false;
     global $wpdb;
     $tableName = Cart66Common::getTableName('email_log');
     $sql = "SELECT * from {$tableName} where id = {$id}";
     $results = $wpdb->get_results($sql);
     if ($results) {
         foreach ($results as $r) {
             $resendEmail = Cart66Notifications::mail($r->to_email, $r->subject, $r->body, $r->headers);
             $email = new Cart66EmailLog();
             $email_data = array('from_email' => $r->from_email, 'from_name' => $r->from_name, 'to_email' => $r->to_email, 'to_name' => $r->to_name, 'head' => array('headers' => $r->headers), 'subject' => $r->subject, 'msg' => $r->body, 'attachments' => $r->attachments, 'order_id' => $r->order_id);
             if (!$resendEmail) {
                 if (Cart66Setting::getValue('log_resent_emails')) {
                     $email->saveEmailLog($email_data, $r->email_type, $r->copy, 'RESEND FAILED');
                 }
             } else {
                 if (Cart66Setting::getValue('log_resent_emails')) {
                     $email->saveEmailLog($email_data, $r->email_type, $r->copy, 'RESEND SUCCESSFUL');
                 }
             }
         }
     }
     return $resendEmail;
 }
 public function sendEmail($email_data)
 {
     $isSent = false;
     $isSent = $this->mail($email_data['to_email'], $email_data['subject'], $email_data['msg'], $email_data['head']['headers']);
     $log = new Cart66EmailLog();
     if (!$isSent) {
         Cart66Common::log("Mail not sent to: " . $email_data['to_email']);
         if (Cart66Setting::getValue('log_' . $email_data['log'])) {
             $log->saveEmailLog($email_data, $email_data['email_type'], 'ORIGINAL', 'FAILED');
         }
     } else {
         if (Cart66Setting::getValue('log_' . $email_data['log'])) {
             $log->saveEmailLog($email_data, $email_data['email_type'], 'ORIGINAL', 'SUCCESSFUL');
         }
     }
     $others = $email_data['copy_to'];
     if ($others) {
         $list = explode(',', $others);
         foreach ($list as $e) {
             $e = trim($e);
             $isSent = $this->mail($e, $email_data['subject'], $email_data['msg_cc'], $email_data['head']['headers']);
             if (!$isSent) {
                 Cart66Common::log("Mail not sent to: {$e}");
                 if (Cart66Setting::getValue('log_' . $email_data['log']) && Cart66Setting::getValue('log_cc_emails')) {
                     $log->saveEmailLog($email_data, $email_data['email_type'], 'COPY', 'FAILED');
                 }
             } else {
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Also mailed to: {$e}");
                 if (Cart66Setting::getValue('log_' . $email_data['log']) && Cart66Setting::getValue('log_cc_emails')) {
                     $log->saveEmailLog($email_data, $email_data['email_type'], 'COPY', 'SUCCESSFUL');
                 }
             }
         }
     }
     return $isSent;
 }