Plugin Directory

Changeset 3483542


Ignore:
Timestamp:
03/16/2026 07:52:11 AM (2 weeks ago)
Author:
yournotify
Message:

Release 2.1.7: use SMTP override for plugin email sends

Location:
yournotify
Files:
37 added
3 edited

Legend:

Unmodified
Added
Removed
  • yournotify/trunk/includes/class-yournotify-email.php

    r3483496 r3483542  
    55
    66class Yournotify_Email {
    7     public function send_email($title, $subject, $html, $text = '', $status = 'draft', $from = '', $to = null, $name = '', $attribs = array()) {
    8         $from_email = $from ?: get_option('yournotify_from_email');
    9         $recipient = is_array($to) ? $to : array(array(
     7    protected function smtp_enabled() {
     8        return (bool) get_option('yournotify_smtp_enable');
     9    }
     10
     11    protected function normalize_recipients($to, $name = '', $attribs = array()) {
     12        if (is_array($to)) {
     13            $items = array();
     14            foreach ($to as $item) {
     15                if (is_string($item)) {
     16                    $items[] = array('email' => $item, 'name' => '', 'attribs' => array());
     17                } elseif (is_array($item)) {
     18                    $items[] = array(
     19                        'email' => $item['email'] ?? '',
     20                        'name' => $item['name'] ?? '',
     21                        'attribs' => is_array($item['attribs'] ?? null) ? $item['attribs'] : array(),
     22                    );
     23                }
     24            }
     25            return $items;
     26        }
     27        return array(array(
    1028            'email' => $to,
    1129            'name' => $name,
    1230            'attribs' => is_array($attribs) ? $attribs : array(),
    1331        ));
     32    }
     33
     34    protected function send_via_wp_mail($subject, $html, $text, array $recipients) {
     35        $headers = array('Content-Type: text/html; charset=UTF-8');
     36        foreach ($recipients as $recipient) {
     37            $email = sanitize_email($recipient['email'] ?? '');
     38            if (!$email) {
     39                continue;
     40            }
     41            $body = $html ?: nl2br(esc_html($text));
     42            $sent = wp_mail($email, $subject, $body, $headers);
     43            if (!$sent) {
     44                error_log('Email sending failed via wp_mail for ' . $email);
     45                return false;
     46            }
     47        }
     48        return true;
     49    }
     50
     51    public function send_email($title, $subject, $html, $text = '', $status = 'draft', $from = '', $to = null, $name = '', $attribs = array()) {
     52        $from_email = $from ?: get_option('yournotify_from_email');
     53        $recipients = $this->normalize_recipients($to, $name, $attribs);
     54
     55        if ($this->smtp_enabled()) {
     56            return $this->send_via_wp_mail($subject, $html, $text, $recipients);
     57        }
    1458
    1559        $payload = array(
     
    2367            'status'     => $status,
    2468            'channel'    => 'email',
    25             'lists'      => $recipient,
     69            'lists'      => $recipients,
    2670        );
    2771
  • yournotify/trunk/readme.txt

    r3483496 r3483542  
    44Requires at least: 4.6
    55Tested up to: 6.7
    6 Stable tag: 2.1.6
     6Stable tag: 2.1.7
    77License: GPLv3 or later
    88
     
    6666== Changelog ==
    6767
     68= 2.1.7 =
     69* Route plugin email sends through wp_mail() when SMTP override is enabled.
     70* Load helper classes explicitly from the plugin bootstrap.
     71
     72
    6873= 2.1.6 =
    6974* Normalize plugin API calls to the current Yournotify endpoints.
  • yournotify/trunk/yournotify.php

    r3483496 r3483542  
    44 * Plugin URI: https://yournotify.com
    55 * Description: Yournotify WP Plugin — SMTP, Subscriber Form, Contact Form.
    6  * Version: 2.1.6
     6 * Version: 2.1.7
    77 * Author: Yournotify
    88 * Author URI: https://yournotify.com
     
    5656
    5757// Shortcode/handlers
     58require_once __DIR__ . '/includes/class-yournotify-api.php';
    5859require_once __DIR__ . '/includes/class-yournotify-optin.php';
    5960require_once __DIR__ . '/includes/class-yournotify-contact.php';
    60 require_once __DIR__ . '/includes/class-yournotify-api.php';
     61require_once __DIR__ . '/includes/class-yournotify-email.php';
     62require_once __DIR__ . '/includes/class-yournotify-sms.php';
     63require_once __DIR__ . '/includes/class-yournotify-subscription.php';
     64require_once __DIR__ . '/includes/class-yournotify-automation.php';
     65require_once __DIR__ . '/includes/class-yournotify-drip.php';
     66require_once __DIR__ . '/includes/class-yournotify-woocommerce.php';
    6167// Activation hook for DB tables
    6268if (function_exists('register_activation_hook')) {
Note: See TracChangeset for help on using the changeset viewer.