PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 2.3.1
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v2.3.1
3.5.4 3.5.3 3.5.2 3.5.1 3.4.9 3.5.0 3.4.8 3.4.7 trunk 2.3.1 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6
supportcandy / includes / actions / wpsc_email_notifications.php

wpsc_email_notifications.php in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 2.3.1, at includes/actions/wpsc_email_notifications.php

49 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly
4 }
5
6 global $current_user, $wpscfunction,$wpdb;
7
8 $send_mail_count = get_option('wpsc_en_send_mail_count');
9
10 $from_name = get_option('wpsc_en_from_name','');
11
12 $emails = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}wpsc_email_notification WHERE attemp=0 ORDER BY id ASC LIMIT $send_mail_count ");
13 $fail_emails = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}wpsc_email_notification WHERE attemp <> 0 ORDER BY id ASC LIMIT 1");
14 $all_mails = array_merge($emails, $fail_emails);
15
16 foreach($all_mails as $email){
17
18 $reply_to = $email->reply_to ? $email->reply_to : $email->from_email;
19
20 $headers = "From: {$from_name} <{$email->from_email}>\r\n";
21 $headers .= "Reply-To: {$reply_to}\r\n";
22 $email_addresses = explode(',',$email->bcc_email);
23 foreach ($email_addresses as $email_address) {
24 $headers .= "BCC: {$email_address}\r\n";
25 }
26
27 $headers .= "Content-Type: text/html; charset=utf-8\r\n";
28
29 $mail_status = wp_mail($email->to_email, $email->email_subject, $email->email_body, $headers);
30
31 $attemp = $email->attemp+1;
32 if(!$mail_status){
33 $values=array(
34 'send_date' => date("Y-m-d H:i:s"),
35 'mail_status' => 1,
36 'attemp' => $attemp
37 );
38 $wpdb->update($wpdb->prefix.'wpsc_email_notification', $values, array('id'=>$email->id));
39
40 if($attemp >= 3){
41 do_action('wpsc_after_failed_attemp_mail_sent',$email);
42 $wpdb->delete($wpdb->prefix.'wpsc_email_notification',array('id'=>$email->id));
43 }
44 }else{
45 do_action('wpsc_after_successfully_mail_sent',$email);
46 $wpdb->delete($wpdb->prefix.'wpsc_email_notification',array('id'=>$email->id));
47 }
48 }
49