From bc89bee944ea60477ab772adb5c77aab3774479a Mon Sep 17 00:00:00 2001 From: Lai Power Date: Wed, 3 Jun 2026 21:29:17 +0000 Subject: [PATCH] updated plugin `SMTP Mailer` version 1.1.26 --- wp-content/plugins/smtp-mailer/main.php | 168 +++++++++++++++++++--- wp-content/plugins/smtp-mailer/readme.txt | 40 +++++- 2 files changed, 178 insertions(+), 30 deletions(-) diff --git a/wp-content/plugins/smtp-mailer/main.php b/wp-content/plugins/smtp-mailer/main.php index abe0bed2..eb41630d 100644 --- a/wp-content/plugins/smtp-mailer/main.php +++ b/wp-content/plugins/smtp-mailer/main.php @@ -1,7 +1,8 @@ plugin_url) + if ($this->plugin_url){ return $this->plugin_url; + } return $this->plugin_url = plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__)); } function plugin_path() { - if ($this->plugin_path) + if ($this->plugin_path){ return $this->plugin_path; + } return $this->plugin_path = untrailingslashit(plugin_dir_path(__FILE__)); } @@ -84,7 +87,7 @@ class SMTP_MAILER { function options_menu() { add_options_page(__('SMTP Mailer', 'smtp-mailer'), __('SMTP Mailer', 'smtp-mailer'), 'manage_options', 'smtp-mailer-settings', array($this, 'options_page')); } - + function options_page() { $plugin_tabs = array( 'smtp-mailer-settings' => __('General', 'smtp-mailer'), @@ -94,7 +97,7 @@ class SMTP_MAILER { 'smtp-mailer-settings&action=advanced' => __('Advanced', 'smtp-mailer'), ); $url = "https://wphowto.net/smtp-mailer-plugin-for-wordpress-1482"; - $link_text = sprintf(__('Please visit the SMTP Mailer documentation page for usage instructions.', 'smtp-mailer'), esc_url($url)); + $link_text = sprintf(__('Please visit the SMTP Mailer documentation page for setup instructions.', 'smtp-mailer'), esc_url($url)); $allowed_html_tags = array( 'a' => array( 'href' => array(), @@ -157,7 +160,7 @@ class SMTP_MAILER { $this->general_settings(); } echo ''; - } + } function test_email_settings(){ if(isset($_POST['smtp_mailer_send_test_email'])){ @@ -294,6 +297,14 @@ class SMTP_MAILER { if(isset($_POST['from_name']) && !empty($_POST['from_name'])){ $from_name = sanitize_text_field(stripslashes($_POST['from_name'])); } + $force_from_name = ''; + if(isset($_POST['force_from_name']) && !empty($_POST['force_from_name'])){ + $force_from_name = sanitize_text_field($_POST['force_from_name']); + } + $force_from_email = ''; + if(isset($_POST['force_from_email']) && !empty($_POST['force_from_email'])){ + $force_from_email = sanitize_text_field($_POST['force_from_email']); + } $force_from_address = ''; if(isset($_POST['force_from_address']) && !empty($_POST['force_from_address'])){ $force_from_address = sanitize_text_field($_POST['force_from_address']); @@ -313,19 +324,40 @@ class SMTP_MAILER { $options['smtp_port'] = $smtp_port; $options['from_email'] = $from_email; $options['from_name'] = $from_name; + $options['force_from_name'] = $force_from_name; + $options['force_from_email'] = $force_from_email; $options['force_from_address'] = $force_from_address; $options['disable_ssl_verification'] = $disable_ssl_verification; smtp_mailer_update_option($options); echo '

'; echo __('Settings Saved!', 'smtp-mailer'); echo '

'; - } + } + // + if (isset($_POST['smtp_mailer_delete_options'])) { + if(check_admin_referer('smtp_mailer_delete_options', 'smtp_mailer_delete_options_nonce')) { + delete_option('smtp_mailer_options'); + echo '

'; + echo __('Options deleted!', 'smtp-mailer'); + echo '

'; + } + } $options = smtp_mailer_get_option(); if(!is_array($options)){ $options = smtp_mailer_get_empty_options_array(); } + // Avoid warning notice since this option was added later + if(!isset($options['force_from_name'])){ + $options['force_from_name'] = ''; + } + + // Avoid warning notice since this option was added later + if(!isset($options['force_from_email'])){ + $options['force_from_email'] = ''; + } + // Avoid warning notice since this option was added later if(!isset($options['force_from_address'])){ $options['force_from_address'] = ''; @@ -404,6 +436,18 @@ class SMTP_MAILER {

+ + + value="1"> +

+ + + + + value="1"> +

+ + value="1"> @@ -422,6 +466,10 @@ class SMTP_MAILER {

+
+ +

+
Body = ''; $phpmailer->AltBody = ''; + /* + * Reset encoding to 8-bit, as it may have been automatically downgraded + * to 7-bit by PHPMailer (based on the body contents) in a previous call + * to wp_mail(). + * + * See https://core.trac.wordpress.org/ticket/33972 + */ + $phpmailer->Encoding = PHPMailer\PHPMailer\PHPMailer::ENCODING_8BIT; + // Set "From" name and email. // If we don't have a name from the input headers. @@ -737,13 +806,21 @@ function smtp_mailer_pre_wp_mail($null, $atts) * @param string $from_name Name associated with the "from" email address. */ $from_name = apply_filters( 'wp_mail_from_name', $from_name ); + //force from name if checked + if(isset($options['force_from_name']) && !empty($options['force_from_name'])){ + $from_name = $options['from_name']; + } + //force from email if checked + if(isset($options['force_from_email']) && !empty($options['force_from_email'])){ + $from_email = $options['from_email']; + } //force from address if checked if(isset($options['force_from_address']) && !empty($options['force_from_address'])){ $from_name = $options['from_name']; $from_email = $options['from_email']; } try { - $phpmailer->setFrom( $from_email, $from_name, false ); + $phpmailer->setFrom( $from_email, $from_name ); } catch ( PHPMailer\PHPMailer\Exception $e ) { $mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' ); $mail_error_data['phpmailer_exception_code'] = $e->getCode(); @@ -794,10 +871,10 @@ function smtp_mailer_pre_wp_mail($null, $atts) $phpmailer->addAddress( $address, $recipient_name ); break; case 'cc': - $phpmailer->addCc( $address, $recipient_name ); + $phpmailer->addCC( $address, $recipient_name ); break; case 'bcc': - $phpmailer->addBcc( $address, $recipient_name ); + $phpmailer->addBCC( $address, $recipient_name ); break; case 'reply_to': $phpmailer->addReplyTo( $address, $recipient_name ); @@ -834,9 +911,11 @@ function smtp_mailer_pre_wp_mail($null, $atts) $phpmailer->SMTPAutoTLS = false; //enable debug when sending a test mail if(isset($_POST['smtp_mailer_send_test_email'])){ - $phpmailer->SMTPDebug = 4; - // Ask for HTML-friendly debug output - $phpmailer->Debugoutput = 'html'; + if(is_admin() && current_user_can('manage_options')){ + $phpmailer->SMTPDebug = 4; + // Ask for HTML-friendly debug output + $phpmailer->Debugoutput = 'html'; + } } //disable ssl certificate verification if checked @@ -898,10 +977,6 @@ function smtp_mailer_pre_wp_mail($null, $atts) } } } - - if ( false !== stripos( $content_type, 'multipart' ) && ! empty( $boundary ) ) { - $phpmailer->addCustomHeader( sprintf( 'Content-Type: %s; boundary="%s"', $content_type, $boundary ) ); - } } if ( isset( $attachments ) && ! empty( $attachments ) ) { @@ -915,6 +990,51 @@ function smtp_mailer_pre_wp_mail($null, $atts) } } } + + if ( isset( $embeds ) && ! empty( $embeds ) ) { + foreach ( $embeds as $key => $embed_path ) { + /** + * Filters the arguments for PHPMailer's addEmbeddedImage() method. + * + * @since 6.9.0 + * + * @param array $args { + * An array of arguments for PHPMailer's addEmbeddedImage() method. + * + * @type string $path The path to the file. + * @type string $cid The Content-ID of the image. Default: The key in the embeds array. + * @type string $name The filename of the image. + * @type string $encoding The encoding of the image. Default: 'base64'. + * @type string $type The MIME type of the image. Default: empty string, which lets PHPMailer auto-detect. + * @type string $disposition The disposition of the image. Default: 'inline'. + * } + */ + $embed_args = apply_filters( + 'wp_mail_embed_args', + array( + 'path' => $embed_path, + 'cid' => (string) $key, + 'name' => basename( $embed_path ), + 'encoding' => 'base64', + 'type' => '', + 'disposition' => 'inline', + ) + ); + + try { + $phpmailer->addEmbeddedImage( + $embed_args['path'], + $embed_args['cid'], + $embed_args['name'], + $embed_args['encoding'], + $embed_args['type'], + $embed_args['disposition'] + ); + } catch ( PHPMailer\PHPMailer\Exception $e ) { + continue; + } + } + } /** * Fires after PHPMailer is initialized. @@ -925,7 +1045,7 @@ function smtp_mailer_pre_wp_mail($null, $atts) */ do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) ); - $mail_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' ); + $mail_data = compact( 'to', 'subject', 'message', 'headers', 'attachments', 'embeds' ); // Send! try { @@ -939,15 +1059,17 @@ function smtp_mailer_pre_wp_mail($null, $atts) * process the request without any errors. * * @since 5.9.0 + * @since 6.9.0 The `$embeds` element was added to the `$mail_data` array. * * @param array $mail_data { - * An array containing the email recipient(s), subject, message, headers, and attachments. + * An array containing the email recipient(s), subject, message, headers, attachments, and embeds. * * @type string[] $to Email addresses to send message. * @type string $subject Email subject. * @type string $message Message contents. * @type string[] $headers Additional headers. * @type string[] $attachments Paths to files to attach. + * @type string[] $embeds Paths to files to embed. * } */ do_action( 'wp_mail_succeeded', $mail_data ); @@ -957,12 +1079,12 @@ function smtp_mailer_pre_wp_mail($null, $atts) $mail_data['phpmailer_exception_code'] = $e->getCode(); /** - * Fires after a PHPMailer\PHPMailer\Exception is caught. + * Fires after a PHPMailer exception is caught. * * @since 4.4.0 * * @param WP_Error $error A WP_Error object with the PHPMailer\PHPMailer\Exception message, and an array - * containing the mail recipient, subject, message, headers, and attachments. + * containing the mail recipient, subject, message, headers, attachments, and embeds. */ do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_data ) ); diff --git a/wp-content/plugins/smtp-mailer/readme.txt b/wp-content/plugins/smtp-mailer/readme.txt index b507150a..831b8ab9 100644 --- a/wp-content/plugins/smtp-mailer/readme.txt +++ b/wp-content/plugins/smtp-mailer/readme.txt @@ -2,9 +2,9 @@ Contributors: naa986 Donate link: https://wphowto.net/ Tags: email, mail, smtp, phpmailer -Requires at least: 6.8 -Tested up to: 6.8 -Stable tag: 1.1.18 +Requires at least: 7.0 +Tested up to: 7.0 +Stable tag: 1.1.26 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -14,8 +14,6 @@ Configure a SMTP server to send email from your WordPress site. Configure the wp [SMTP Mailer](https://wphowto.net/smtp-mailer-plugin-for-wordpress-1482) plugin allows you to configure a mail server which handles all outgoing email from your website. It takes control of the wp_mail function and use SMTP instead. -https://www.youtube.com/watch?v=7O_jgtykcEk&rel=0 - === SMTP Mailer Add-ons === * [Reply-To](https://wphowto.net/how-to-add-a-reply-to-address-in-the-smtp-mailer-wordpress-plugin-6997) @@ -29,8 +27,12 @@ https://www.youtube.com/watch?v=7O_jgtykcEk&rel=0 * **SMTP Password**: The password to connect to your SMTP server. * **Type of Encryption**: The encryption to be used when sending an email (TLS/SSL/No Encryption. TLS is recommended). * **SMTP Port**: The port to be used when sending an email (587/465/25). If you choose TLS the port should be set to 587. For SSL use port 465 instead. -* **From Email Address**: The email address to be used as the From Address when sending an email. -* **From Name**: The name to be used as the From Name when sending an email. +* **From Email Address**: The email address to be used as the From Email when sending a test email. +* **From Name**: The name to be used as the From Name when sending a test email. +* **Force From Name**: The From name in the settings is set for all outgoing email messages. +* **Force From Email**: The From email in the settings is set for all outgoing email messages. +* **Force From Address**: The From address in the settings is set for all outgoing email messages. +* **Disable SSL Certificate Verification**: As of PHP 5.6 a warning/error is shown if the SSL certificate on the server is not properly configured. This option lets you disable that behaviour. === SMTP Mailer Test Email === @@ -73,6 +75,30 @@ none == Changelog == += 1.1.26 = +* WordPress 7.0 compatibility update. + += 1.1.25 = +* Added security for debug output. + += 1.1.24 = +* WordPress 6.9 compatibility update. + += 1.1.23 = +* Added options to force from name and from email. + += 1.1.22 = +* Added minimum WordPress requirements to main file. + += 1.1.21 = +* Added an option to delete saved options. + += 1.1.20 = +* Restored older settings. + += 1.1.19 = +* Added a menu for easy configuration. + = 1.1.18 = * WordPress 6.8 compatibility update.