function proces_subissions()
 {
     if (wp_verify_nonce($_POST['wpem_send_mail_nonce'], 'wpem_send_mail')) {
         $mail = EM_Mailer::send_mail($_REQUEST['mail']);
         if (is_integer($mail)) {
             $location = add_query_arg('message', 1, admin_url('admin.php?page=wpem_mail&recepients=' . absint($mail)));
             wp_redirect($location);
         }
         $this->submit_results = $mail;
     }
 }
 public static function process_schedules()
 {
     $schedules = get_option('wpem-schedules');
     $day_now = strtotime(date('Y-m-d'));
     $mail_sent = $count = 0;
     foreach ((array) $schedules as $schedule) {
         $next_send = self::next_send(strtotime($schedule['start_date']), $schedule['frequency'], strtotime($schedule['end_date']));
         if ($day_now == $next_send) {
             $mail_sent += EM_Mailer::send_mail($schedule);
             $count++;
         }
     }
     if ($mail_sent) {
         add_notice(sprintf(__('%s scheduled emails were sent to %s email addresses', 'wpem'), $count, $mail_sent));
     }
 }
Пример #3
0
 case 'test_mail':
     $ms = WPEM()->modules['settings']->settings['mail'];
     $mail['source'] = array('id' => 'sm');
     $mail['mail_format'] = $_REQUEST['m_format'];
     $mail['from_email'] = !empty($ms['from_sender_email']) ? $ms['from_sender_email'] : get_option('admin_email');
     $mail['from_name'] = !empty($ms['from_sender_name']) ? $ms['from_sender_name'] : get_bloginfo('name');
     $mail['title'] = __('Test Mail', 'wpem');
     $mail['body'] = $_REQUEST['m_body'];
     $mail['template'] = $_REQUEST['temp_id'];
     $current_user = get_user_by('id', get_current_user_id());
     $full_names = !empty($current_user->first_name) || !empty($current_user->last_name) ? ucfirst($current_user->first_name) . ' ' . ucfirst($current_user->last_name) : $current_user->display_name;
     $mail['to_email'] = $current_user->user_email;
     $mail['to_name'] = $full_names;
     $json = array();
     try {
         $mail = EM_Mailer::send_mail($mail);
         if (is_integer($mail)) {
             global $user_email;
             $json['sent'] = sprintf(__('Test email sent to %s', 'wpem'), $user_email);
         } else {
             if (isset($mail['errors'])) {
                 if ($errmsg = $mail['errors']->get_error_message('body')) {
                     $json['error'] = $errmsg;
                 } else {
                     print_r($mail['errors']);
                 }
             }
         }
         echo json_encode($json);
     } catch (Exception $e) {
         ?>