'+o+""),u.find("span.status-label").removeClass("status-active status-inactive status-download").addClass(n).removeClass("button button-primary button-secondary disabled").text(l),i.removeClass("status-active status-inactive status-download").removeClass("button button-primary button-secondary disabled").addClass(n).html(e)):(t=!1,a.hasOwnProperty("data")&&a.data.hasOwnProperty(0)&&a.data[0].hasOwnProperty("code")?u.find(".actions").append(''+wp_mail_smtp_about.plugin_install_error+"
"):u.find(".actions").append(''+a.data+"
"),i.html(wp_mail_smtp_about.plugin_download_btn)),t||i.removeClass("disabled"),i.removeClass("loading"),setTimeout(function(){d(".plugin-item .msg").remove()},3e3)}).fail(function(a){console.log(a.responseText)})})}};return i}(document,window,jQuery),WPMailSMTP.Admin.About.init();
--------------------------------------------------------------------------------
/assets/js/smtp-admin-notices.js:
--------------------------------------------------------------------------------
1 | /* global wp_mail_smtp_admin_notices, ajaxurl */
2 |
3 | /**
4 | * WP Mail SMTP Admin Notices.
5 | *
6 | * @since 4.4.0
7 | */
8 |
9 | 'use strict';
10 |
11 | var WPMailSMTPAdminNotices = window.WPMailSMTPAdminNotices || ( function( document, window, $ ) {
12 |
13 | /**
14 | * Public functions and properties.
15 | *
16 | * @since 4.4.0
17 | *
18 | * @type {object}
19 | */
20 | var app = {
21 |
22 | /**
23 | * Start the engine.
24 | *
25 | * @since 4.4.0
26 | */
27 | init: function() {
28 |
29 | $( app.ready );
30 | },
31 |
32 | /**
33 | * Document ready.
34 | *
35 | * @since 4.4.0
36 | */
37 | ready: function() {
38 |
39 | app.events();
40 | },
41 |
42 | /**
43 | * Register JS events.
44 | *
45 | * @since 4.4.0
46 | */
47 | events: function() {
48 |
49 | $( '.wp-mail-smtp-notice.is-dismissible' )
50 | .on( 'click', '.notice-dismiss', app.dismiss );
51 | },
52 |
53 | /**
54 | * Click on the dismiss notice button.
55 | *
56 | * @since 4.4.0
57 | *
58 | * @param {object} event Event object.
59 | */
60 | dismiss: function( event ) {
61 |
62 | var $notice = $( this ).closest( '.wp-mail-smtp-notice' );
63 |
64 | // If notice key is not defined, we can't dismiss it permanently.
65 | if ( $notice.data( 'notice' ) === undefined ) {
66 | return;
67 | }
68 |
69 | var $button = $( this );
70 |
71 | $.ajax( {
72 | url: ajaxurl,
73 | dataType: 'json',
74 | type: 'POST',
75 | data: {
76 | action: 'wp_mail_smtp_ajax',
77 | nonce: wp_mail_smtp_admin_notices.nonce,
78 | task: 'notice_dismiss',
79 | notice: $notice.data( 'notice' ),
80 | },
81 | beforeSend: function() {
82 | $button.prop( 'disabled', true );
83 | },
84 | } );
85 | },
86 | };
87 |
88 | return app;
89 |
90 | }( document, window, jQuery ) );
91 |
92 | // Initialize.
93 | WPMailSMTPAdminNotices.init();
94 |
--------------------------------------------------------------------------------
/assets/js/smtp-admin-notices.min.js:
--------------------------------------------------------------------------------
1 | "use strict";var WPMailSMTPAdminNotices=window.WPMailSMTPAdminNotices||function(s){var i={init:function(){s(i.ready)},ready:function(){i.events()},events:function(){s(".wp-mail-smtp-notice.is-dismissible").on("click",".notice-dismiss",i.dismiss)},dismiss:function(i){var n,t=s(this).closest(".wp-mail-smtp-notice");void 0!==t.data("notice")&&(n=s(this),s.ajax({url:ajaxurl,dataType:"json",type:"POST",data:{action:"wp_mail_smtp_ajax",nonce:wp_mail_smtp_admin_notices.nonce,task:"notice_dismiss",notice:t.data("notice")},beforeSend:function(){n.prop("disabled",!0)}}))}};return i}((document,window,jQuery));WPMailSMTPAdminNotices.init();
--------------------------------------------------------------------------------
/assets/js/smtp-notifications.min.js:
--------------------------------------------------------------------------------
1 | "use strict";var WPMailSMTPAdminNotifications=window.WPMailSMTPAdminNotifications||function(t){var a={$notifications:t("#wp-mail-smtp-notifications"),$nextButton:t("#wp-mail-smtp-notifications .navigation .next"),$prevButton:t("#wp-mail-smtp-notifications .navigation .prev"),$adminBarCounter:t("#wp-admin-bar-wp-mail-smtp-menu .wp-mail-smtp-admin-bar-menu-notification-counter")},i={init:function(){t(i.ready)},ready:function(){i.updateNavigation(),i.events()},events:function(){a.$notifications.on("click",".dismiss",i.dismiss).on("click",".next",i.navNext).on("click",".prev",i.navPrev)},dismiss:function(e){var n;0!==a.$currentMessage.length&&(n={action:"wp_mail_smtp_notification_dismiss",nonce:wp_mail_smtp.nonce,id:a.$currentMessage.data("message-id")},t.post(ajaxurl,n,function(e){e.success&&(1<(e=parseInt(a.$adminBarCounter.text(),10))?a.$adminBarCounter.html(""+--e+""):a.$adminBarCounter.remove(),0===(e=a.$nextMessage.length<1?a.$prevMessage:a.$nextMessage).length?a.$notifications.remove():(a.$currentMessage.remove(),e.addClass("current"),i.updateNavigation()))}))},navNext:function(e){a.$nextButton.hasClass("disabled")||(a.$currentMessage.removeClass("current"),a.$nextMessage.addClass("current"),i.updateNavigation())},navPrev:function(e){a.$prevButton.hasClass("disabled")||(a.$currentMessage.removeClass("current"),a.$prevMessage.addClass("current"),i.updateNavigation())},updateNavigation:function(){a.$currentMessage=a.$notifications.find(".wp-mail-smtp-notifications-message.current"),a.$nextMessage=a.$currentMessage.next(".wp-mail-smtp-notifications-message"),a.$prevMessage=a.$currentMessage.prev(".wp-mail-smtp-notifications-message"),0===a.$nextMessage.length?a.$nextButton.addClass("disabled"):a.$nextButton.removeClass("disabled"),0===a.$prevMessage.length?a.$prevButton.addClass("disabled"):a.$prevButton.removeClass("disabled")}};return i}((document,window,jQuery));WPMailSMTPAdminNotifications.init();
--------------------------------------------------------------------------------
/assets/js/vendor/chartjs-adapter-moment.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * chartjs-adapter-moment v1.0.1
3 | * https://www.chartjs.org
4 | * (c) 2022 chartjs-adapter-moment Contributors
5 | * Released under the MIT license
6 | *
7 | * NOTE: This file was modified. Chart object was renamed to WPMailSMTPChart, to prevent JS library conflicts with other plugins.
8 | * "Chart" was replaced with "WPMailSMTPChart" 1 time in this file.
9 | */
10 | !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("moment"),require("chart.js")):"function"==typeof define&&define.amd?define(["moment","chart.js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).moment,e.WPMailSMTPChart)}(this,(function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=n(e);const a={datetime:"MMM D, YYYY, h:mm:ss a",millisecond:"h:mm:ss.SSS a",second:"h:mm:ss a",minute:"h:mm a",hour:"hA",day:"MMM D",week:"ll",month:"MMM YYYY",quarter:"[Q]Q - YYYY",year:"YYYY"};t._adapters._date.override("function"==typeof f.default?{_id:"moment",formats:function(){return a},parse:function(e,t){return"string"==typeof e&&"string"==typeof t?e=f.default(e,t):e instanceof f.default||(e=f.default(e)),e.isValid()?e.valueOf():null},format:function(e,t){return f.default(e).format(t)},add:function(e,t,n){return f.default(e).add(t,n).valueOf()},diff:function(e,t,n){return f.default(e).diff(f.default(t),n)},startOf:function(e,t,n){return e=f.default(e),"isoWeek"===t?(n=Math.trunc(Math.min(Math.max(0,n),6)),e.isoWeekday(n).startOf("day").valueOf()):e.startOf(t).valueOf()},endOf:function(e,t){return f.default(e).endOf(t).valueOf()}}:{})}));
--------------------------------------------------------------------------------
/assets/vue/img/arrow.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/brevo.svg:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/assets/vue/img/check-circle-solid-white.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/check-circle-solid.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/check-solid.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/chevron-down-solid-grey.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/copy-solid.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/elasticemail.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/exclamation-circle-solid.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/gmail-sign-in-btn.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/assets/vue/img/gmail.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/info-circle-solid.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/loading-blue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/loading-white.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/loading.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/lock-solid.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/long-arrow-alt-left-regular-grey.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/long-arrow-alt-left-regular.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/long-arrow-alt-right-regular-white.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/long-arrow-alt-right-regular.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/mailersend.svg:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/assets/vue/img/mailgun.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/mailjet.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/outlook-sign-in-btn.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/assets/vue/img/outlook.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/postmark.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/pro-badge.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/question-circle-solid.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/sendgrid.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/sendlayer.svg:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/assets/vue/img/smtp.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/smtp2go.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/smtpcom.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/sparkpost.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/star-solid.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/thumbs-down-hover.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/thumbs-down.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/thumbs-up-hover.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/thumbs-up.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/times-solid-grey.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/vue/img/times-solid.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/wporg/banner-1544x500.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/banner-1544x500.png
--------------------------------------------------------------------------------
/assets/wporg/banner-772x250.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/banner-772x250.png
--------------------------------------------------------------------------------
/assets/wporg/icon-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/icon-128x128.png
--------------------------------------------------------------------------------
/assets/wporg/icon-256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/icon-256x256.png
--------------------------------------------------------------------------------
/assets/wporg/screenshot-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/screenshot-1.png
--------------------------------------------------------------------------------
/assets/wporg/screenshot-10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/screenshot-10.png
--------------------------------------------------------------------------------
/assets/wporg/screenshot-11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/screenshot-11.png
--------------------------------------------------------------------------------
/assets/wporg/screenshot-12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/screenshot-12.png
--------------------------------------------------------------------------------
/assets/wporg/screenshot-13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/screenshot-13.png
--------------------------------------------------------------------------------
/assets/wporg/screenshot-14.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/screenshot-14.png
--------------------------------------------------------------------------------
/assets/wporg/screenshot-15.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/screenshot-15.png
--------------------------------------------------------------------------------
/assets/wporg/screenshot-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/screenshot-16.png
--------------------------------------------------------------------------------
/assets/wporg/screenshot-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/screenshot-2.png
--------------------------------------------------------------------------------
/assets/wporg/screenshot-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/screenshot-3.png
--------------------------------------------------------------------------------
/assets/wporg/screenshot-4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/screenshot-4.png
--------------------------------------------------------------------------------
/assets/wporg/screenshot-5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/screenshot-5.png
--------------------------------------------------------------------------------
/assets/wporg/screenshot-6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/screenshot-6.png
--------------------------------------------------------------------------------
/assets/wporg/screenshot-7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/screenshot-7.png
--------------------------------------------------------------------------------
/assets/wporg/screenshot-8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/screenshot-8.png
--------------------------------------------------------------------------------
/assets/wporg/screenshot-9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesomemotive/WP-Mail-SMTP/d4baca4dee74e605fbc67825dda0c913ac2c3e9e/assets/wporg/screenshot-9.png
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "wp-mail-smtp",
3 | "version": "4.5.0",
4 | "description": "Make email delivery easy for WordPress. Connect with SMTP, Gmail, Outlook, SendGrid, Mailgun, Zoho, SES, and more.",
5 | "private": true,
6 | "repository": {
7 | "type": "git",
8 | "url": "git+https://github.com/awesomemotive/wp-mail-smtp.git"
9 | },
10 | "license": "GPL-2.0+",
11 | "bugs": {
12 | "url": "https://github.com/awesomemotive/wp-mail-smtp/issues"
13 | },
14 | "homepage": "https://wpmailsmtp.com",
15 | "devDependencies": {
16 | "babel-eslint": "^10.0.3",
17 | "cross-env": "^7.0.0",
18 | "eslint": "^6.8.0",
19 | "eslint-config-wordpress": "^2.0.0",
20 | "eslint-plugin-jsdoc": "^22.1.0",
21 | "eslint-plugin-vue": "^6.2.2",
22 | "vue-eslint-parser": "^7.11.0",
23 | "gulp": "^4.0.2",
24 | "gulp-cached": "^1.1.1",
25 | "gulp-clean": "^0.4.0",
26 | "gulp-debug": "^5.0.1",
27 | "gulp-imagemin": "^9.0.0",
28 | "gulp-include": "^2.4.1",
29 | "gulp-rename": "^1.4.0",
30 | "gulp-replace": "^1.1.4",
31 | "gulp-sass": "^5.1.0",
32 | "gulp-sourcemaps": "^2.6.5",
33 | "gulp-uglify": "^3.0.2",
34 | "gulp-watch": "^5.0.1",
35 | "gulp-zip": "^4.2.0",
36 | "husky": "^9.0.11",
37 | "lint-diff": "file:.packages/npm/lint-diff",
38 | "lodash": "^4.17.21",
39 | "merge-stream": "^2.0.0",
40 | "npm-run-all": "^4.1.5",
41 | "sass": "^1.69.6",
42 | "trim-newlines": "^5.0.0",
43 | "y18n": "^5.0.8",
44 | "yargs": "^17.7.2",
45 | "yargs-parser": "^13.1.2"
46 | },
47 | "engines": {
48 | "node": ">=18.19.0 <20.0.0",
49 | "npm": ">=10.2.3"
50 | },
51 | "scripts": {
52 | "gulp": "node ./node_modules/gulp/bin/gulp.js",
53 | "lint-diff": "cross-env node node_modules/lint-diff/dist/lint-diff.js",
54 | "phpcs-diff": "cross-env php vendor/bin/phpcs-diff",
55 | "cs": "run-s --silent --continue-on-error lint-diff phpcs-diff"
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/php-scoper/check-build-php-version.php:
--------------------------------------------------------------------------------
1 | =' ) && version_compare( phpversion(), '7.4', '<=' ) ) {
5 | echo 'Your PHP version is not correct (' . phpversion() . ')! Please use PHP 7.4 for executing this composer script.' . PHP_EOL;
6 |
7 | exit( 1 );
8 | }
9 |
--------------------------------------------------------------------------------
/php-scoper/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "require": {
3 | "humbug/php-scoper": "^0.14.1"
4 | },
5 | "minimum-stability": "dev",
6 | "prefer-stable": true,
7 | "config": {
8 | "preferred-install": "dist",
9 | "sort-packages": true
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/AbstractConnection.php:
--------------------------------------------------------------------------------
1 | get_name(),
26 | wp_mail_smtp()->get_providers()->get_options( $this->get_mailer_slug(), $this )->get_title()
27 | );
28 | }
29 |
30 | /**
31 | * Get connection mailer slug.
32 | *
33 | * @since 3.7.0
34 | *
35 | * @return string
36 | */
37 | public function get_mailer_slug() {
38 |
39 | return $this->get_options()->get( 'mail', 'mailer' );
40 | }
41 |
42 | /**
43 | * Get connection mailer object.
44 | *
45 | * @since 3.7.0
46 | *
47 | * @return MailerAbstract
48 | */
49 | public function get_mailer() {
50 |
51 | $phpmailer = wp_mail_smtp()->get_processor()->get_phpmailer();
52 |
53 | return wp_mail_smtp()->get_providers()->get_mailer( $this->get_mailer_slug(), $phpmailer, $this );
54 | }
55 |
56 | /**
57 | * Whether the connection is primary or not.
58 | *
59 | * @since 3.7.0
60 | *
61 | * @return bool
62 | */
63 | public function is_primary() {
64 |
65 | return false;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/Admin/DebugEvents/Migration.php:
--------------------------------------------------------------------------------
1 | get_charset_collate();
46 |
47 | $sql = "CREATE TABLE IF NOT EXISTS `$table` (
48 | `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
49 | `content` TEXT DEFAULT NULL,
50 | `initiator` TEXT DEFAULT NULL,
51 | `event_type` TINYINT UNSIGNED NOT NULL DEFAULT '0',
52 | `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
53 | PRIMARY KEY (id)
54 | )
55 | ENGINE='InnoDB'
56 | {$charset_collate};";
57 |
58 | $result = $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
59 |
60 | if ( ! empty( $wpdb->last_error ) ) {
61 | update_option( self::ERROR_OPTION_NAME, $wpdb->last_error, false );
62 | }
63 |
64 | // Save the current version to DB.
65 | if ( $result !== false ) {
66 | $this->update_db_ver( 1 );
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/Admin/PageInterface.php:
--------------------------------------------------------------------------------
1 | get_tab_label( $tab );
48 | }
49 |
50 | return esc_html__( 'About Us', 'wp-mail-smtp' );
51 | }
52 |
53 | /**
54 | * Title of a page.
55 | *
56 | * @since 1.5.0
57 | *
58 | * @return string
59 | */
60 | public function get_title() {
61 |
62 | return $this->get_label();
63 | }
64 |
65 | /**
66 | * Active the given plugin.
67 | *
68 | * @deprecated 2.9.0
69 | *
70 | * @since 1.5.0
71 | */
72 | public static function ajax_plugin_activate() {
73 |
74 | _deprecated_function( __METHOD__, '2.9.0', '\WPMailSMTP\Admin\Pages\AboutTab::ajax_plugin_activate' );
75 |
76 | AboutTab::ajax_plugin_activate();
77 | }
78 |
79 | /**
80 | * Install & activate the given plugin.
81 | *
82 | * @deprecated 2.9.0
83 | *
84 | * @since 1.5.0
85 | */
86 | public static function ajax_plugin_install() {
87 |
88 | _deprecated_function( __METHOD__, '2.9.0', '\WPMailSMTP\Admin\Pages\AboutTab::ajax_plugin_install' );
89 |
90 | AboutTab::ajax_plugin_install();
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/src/Admin/Pages/AuthTab.php:
--------------------------------------------------------------------------------
1 | get_connections_manager()->get_primary_connection();
28 |
29 | /**
30 | * Filters auth connection object.
31 | *
32 | * @since 3.7.0
33 | *
34 | * @param ConnectionInterface $connection The Connection object.
35 | */
36 | $connection = apply_filters( 'wp_mail_smtp_admin_pages_auth_tab_process_auth_connection', $connection );
37 |
38 | $auth = wp_mail_smtp()->get_providers()->get_auth( $connection->get_mailer_slug(), $connection );
39 |
40 | if (
41 | $auth &&
42 | $auth instanceof AuthAbstract &&
43 | method_exists( $auth, 'process' )
44 | ) {
45 | $auth->process();
46 | }
47 | }
48 |
49 | /**
50 | * Return nothing, as we don't need this functionality.
51 | *
52 | * @since 1.0.0
53 | */
54 | public function get_label() {
55 | return '';
56 | }
57 |
58 | /**
59 | * Return nothing, as we don't need this functionality.
60 | *
61 | * @since 1.0.0
62 | */
63 | public function get_title() {
64 | return '';
65 | }
66 |
67 | /**
68 | * Do nothing, as we don't need this functionality.
69 | *
70 | * @since 1.0.0
71 | */
72 | public function display() {
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/Admin/Pages/EmailReports.php:
--------------------------------------------------------------------------------
1 | get_label();
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/Admin/Pages/Logs.php:
--------------------------------------------------------------------------------
1 | slug,
36 | WP::admin_url( 'admin.php?page=' . Area::SLUG )
37 | );
38 | }
39 |
40 | /**
41 | * Link label of a tab.
42 | *
43 | * @since 1.5.0
44 | *
45 | * @return string
46 | */
47 | public function get_label() {
48 | return esc_html__( 'Email Log', 'wp-mail-smtp' );
49 | }
50 |
51 | /**
52 | * Title of a tab.
53 | *
54 | * @since 1.5.0
55 | *
56 | * @return string
57 | */
58 | public function get_title() {
59 | return $this->get_label();
60 | }
61 |
62 | /**
63 | * Tab content.
64 | *
65 | * @since 2.1.0 Moved the display content to the email log settings tab.
66 | */
67 | public function display() {}
68 | }
69 |
--------------------------------------------------------------------------------
/src/Admin/Pages/Tools.php:
--------------------------------------------------------------------------------
1 | get_label();
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/Admin/PluginsInstallSkin.php:
--------------------------------------------------------------------------------
1 | setup_compatibility();
32 | }
33 |
34 | /**
35 | * Setup compatibility plugins.
36 | *
37 | * @since 2.8.0
38 | */
39 | public function setup_compatibility() {
40 |
41 | $plugins = [
42 | 'admin-2020' => '\WPMailSMTP\Compatibility\Plugin\Admin2020',
43 | 'wpforms-lite' => '\WPMailSMTP\Compatibility\Plugin\WPFormsLite',
44 | 'wpforms' => '\WPMailSMTP\Compatibility\Plugin\WPForms',
45 | 'woocommerce' => '\WPMailSMTP\Compatibility\Plugin\WooCommerce',
46 | ];
47 |
48 | foreach ( $plugins as $key => $classname ) {
49 | if ( class_exists( $classname ) && is_callable( [ $classname, 'is_applicable' ] ) ) {
50 | if ( $classname::is_applicable() ) {
51 | $this->plugins[ $key ] = new $classname();
52 | }
53 | }
54 | }
55 | }
56 |
57 | /**
58 | * Get compatibility plugin.
59 | *
60 | * @since 2.8.0
61 | *
62 | * @param string $key Plugin key.
63 | *
64 | * @return \WPMailSMTP\Compatibility\Plugin\PluginAbstract | false
65 | */
66 | public function get_plugin( $key ) {
67 |
68 | return isset( $this->plugins[ $key ] ) ? $this->plugins[ $key ] : false;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/Compatibility/Plugin/Admin2020.php:
--------------------------------------------------------------------------------
1 | after_plugins_loaded();
28 | }
29 |
30 | /**
31 | * Is plugin can be loaded.
32 | *
33 | * @since 2.8.0
34 | *
35 | * @return bool
36 | */
37 | public static function is_applicable() {
38 |
39 | return static::is_activated();
40 | }
41 |
42 | /**
43 | * Is plugin activated.
44 | *
45 | * @since 2.8.0
46 | *
47 | * @return bool
48 | */
49 | public static function is_activated() {
50 |
51 | return WP::is_plugin_activated( static::get_path() );
52 | }
53 |
54 | /**
55 | * Execute after plugins loaded.
56 | *
57 | * @since 2.8.0
58 | */
59 | public function after_plugins_loaded() {
60 | }
61 |
62 | /**
63 | * Execute on init action in admin area.
64 | *
65 | * @since 2.8.0
66 | */
67 | public function load_admin() {
68 | }
69 |
70 | /**
71 | * Execute on init action.
72 | *
73 | * @since 2.8.0
74 | */
75 | public function load() {
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/Compatibility/Plugin/PluginInterface.php:
--------------------------------------------------------------------------------
1 | get_queue()->is_enabled() ) {
44 | add_filter( 'wpforms_tasks_entry_emails_trigger_send_same_process', '__return_true', PHP_INT_MAX );
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/Compatibility/Plugin/WooCommerce.php:
--------------------------------------------------------------------------------
1 | get_queue()->is_enabled() ) {
44 | add_filter( 'woocommerce_defer_transactional_emails', '__return_false', PHP_INT_MAX );
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/Connection.php:
--------------------------------------------------------------------------------
1 | options = Options::init();
29 | }
30 |
31 | /**
32 | * Get the connection identifier.
33 | *
34 | * @since 3.7.0
35 | *
36 | * @return string
37 | */
38 | public function get_id() {
39 |
40 | return 'primary';
41 | }
42 |
43 | /**
44 | * Get the connection name.
45 | *
46 | * @since 3.7.0
47 | *
48 | * @return string
49 | */
50 | public function get_name() {
51 |
52 | return esc_html__( 'Primary', 'wp-mail-smtp' );
53 | }
54 |
55 | /**
56 | * Get connection options object.
57 | *
58 | * @since 3.7.0
59 | *
60 | * @return Options
61 | */
62 | public function get_options() {
63 |
64 | return $this->options;
65 | }
66 |
67 | /**
68 | * Whether the connection is primary or not.
69 | *
70 | * @since 3.7.0
71 | *
72 | * @return bool
73 | */
74 | public function is_primary() {
75 |
76 | return true;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/ConnectionInterface.php:
--------------------------------------------------------------------------------
1 | get_primary_connection();
31 | }
32 |
33 | /**
34 | * Get the primary connection object.
35 | *
36 | * @since 3.7.0
37 | *
38 | * @return ConnectionInterface
39 | */
40 | public function get_primary_connection() {
41 |
42 | if ( is_null( $this->primary_connection ) ) {
43 | $this->primary_connection = new Connection();
44 | }
45 |
46 | return $this->primary_connection;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/Helpers/DB.php:
--------------------------------------------------------------------------------
1 | prepare(
27 | 'SELECT COUNT(1) IndexIsThere
28 | FROM INFORMATION_SCHEMA.STATISTICS
29 | WHERE table_schema = DATABASE()
30 | AND table_name = %s
31 | AND index_name = %s',
32 | $table,
33 | $index
34 | );
35 |
36 | // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
37 | $result = $wpdb->get_var( $query );
38 |
39 | return $result === '1';
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/MailCatcher.php:
--------------------------------------------------------------------------------
1 | CustomHeader; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
46 | }
47 |
48 | /**
49 | * Get the PHPMailer line ending.
50 | *
51 | * @since 2.2.0
52 | *
53 | * @return string
54 | */
55 | public function get_line_ending() {
56 |
57 | return $this->LE; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
58 | }
59 |
60 | /**
61 | * Throw PHPMailer exception.
62 | *
63 | * @since 4.0.0
64 | *
65 | * @param string $error Error message.
66 | *
67 | * @throws phpmailerException PHPMailer exception.
68 | */
69 | protected function throw_exception( $error ) {
70 |
71 | throw new phpmailerException( $error );
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/MailCatcherInterface.php:
--------------------------------------------------------------------------------
1 | get( 'general', self::SETTINGS_SLUG );
56 |
57 | return (bool) $value;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/Providers/AmazonSES/Options.php:
--------------------------------------------------------------------------------
1 | wp_mail_smtp()->assets_url . '/images/providers/aws.svg',
24 | 'slug' => 'amazonses',
25 | 'title' => esc_html__( 'Amazon SES', 'wp-mail-smtp' ),
26 | 'disabled' => true,
27 | )
28 | );
29 | }
30 |
31 | /**
32 | * @inheritdoc
33 | */
34 | public function display_options() {
35 |
36 | ?>
37 |
42 | Server:';
23 |
24 | $disabled_functions = ini_get( 'disable_functions' );
25 | $disabled = (array) explode( ',', trim( $disabled_functions ) );
26 |
27 | $mail_text[] = 'PHP.mail(): ' . ( in_array( 'mail', $disabled, true ) || ! function_exists( 'mail' ) ? 'No' : 'Yes' );
28 | if ( function_exists( 'apache_get_modules' ) ) {
29 | $modules = apache_get_modules();
30 | $mail_text[] = 'Apache.mod_security: ' . ( in_array( 'mod_security', $modules, true ) || in_array( 'mod_security2', $modules, true ) ? 'Yes' : 'No' );
31 | }
32 | if ( function_exists( 'selinux_is_enabled' ) ) {
33 | $mail_text[] = 'OS.SELinux: ' . ( selinux_is_enabled() ? 'Yes' : 'No' );
34 | }
35 | if ( function_exists( 'grsecurity_is_enabled' ) ) {
36 | $mail_text[] = 'OS.grsecurity: ' . ( grsecurity_is_enabled() ? 'Yes' : 'No' );
37 | }
38 |
39 | return implode( '
', $mail_text );
40 | }
41 |
42 | /**
43 | * @inheritdoc
44 | */
45 | public function is_mailer_complete() {
46 |
47 | return true;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/Providers/Mail/Options.php:
--------------------------------------------------------------------------------
1 | wp_mail_smtp()->assets_url . '/images/providers/php.svg',
25 | 'slug' => 'mail',
26 | 'title' => esc_html__( 'Default (none)', 'wp-mail-smtp' ),
27 | )
28 | );
29 | }
30 |
31 | /**
32 | * @inheritdoc
33 | */
34 | public function display_options() {
35 | ?>
36 |
37 |
38 | Default (none) mailer selected, which won\'t improve email deliverability. Please select any other email provider and use the easy Setup Wizard to configure it.', 'wp-mail-smtp' ),
42 | [
43 | 'strong' => [],
44 | 'a' => [
45 | 'href' => [],
46 | 'rel' => [],
47 | 'target' => [],
48 | ],
49 | ]
50 | ),
51 | esc_url( wp_mail_smtp()->get_utm_url( 'https://wpmailsmtp.com/docs/a-complete-guide-to-wp-mail-smtp-mailers/', 'Default mailer - any other email provider' ) ),
52 | esc_url( SetupWizard::get_site_url() )
53 | );
54 | ?>
55 |
56 |
57 | wp_mail_smtp()->assets_url . '/images/providers/microsoft.svg',
24 | 'slug' => 'outlook',
25 | 'title' => esc_html__( '365 / Outlook', 'wp-mail-smtp' ),
26 | 'disabled' => true,
27 | )
28 | );
29 | }
30 |
31 | /**
32 | * @inheritdoc
33 | */
34 | public function display_options() {
35 |
36 | ?>
37 |
42 | options->get_group( $this->mailer );
21 |
22 | // Host and Port are the only really required options.
23 | if (
24 | ! empty( $options['host'] ) &&
25 | ! empty( $options['port'] )
26 | ) {
27 | return true;
28 | }
29 |
30 | return false;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Providers/Pepipost/Options.php:
--------------------------------------------------------------------------------
1 | wp_mail_smtp()->assets_url . '/images/providers/pepipost-smtp.png',
24 | 'slug' => 'pepipost',
25 | 'title' => esc_html__( 'Pepipost SMTP', 'wp-mail-smtp' ),
26 | )
27 | );
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Providers/SMTP/Mailer.php:
--------------------------------------------------------------------------------
1 | connection_options->get_group( $this->mailer );
21 |
22 | // Host and Port are the only really required options.
23 | if (
24 | ! empty( $options['host'] ) &&
25 | ! empty( $options['port'] )
26 | ) {
27 | return true;
28 | }
29 |
30 | return false;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Providers/SMTP/Options.php:
--------------------------------------------------------------------------------
1 | wp_mail_smtp()->assets_url . '/images/providers/smtp.svg',
27 | 'slug' => 'smtp',
28 | 'title' => esc_html__( 'Other SMTP', 'wp-mail-smtp' ),
29 | 'description' => sprintf(
30 | wp_kses(
31 | /* translators: %s - URL to SMTP documentation. */
32 | __( 'The Other SMTP option lets you send emails through an SMTP server instead of using a provider\'s API. This is easy and convenient, but it\'s less secure than the other mailers. Please note that your provider may not allow you to send a large number of emails. In that case, please use a different mailer.
To get started, read our Other SMTP documentation.', 'wp-mail-smtp' ),
33 | [
34 | 'br' => [],
35 | 'a' => [
36 | 'href' => [],
37 | 'rel' => [],
38 | 'target' => [],
39 | ],
40 | ]
41 | ),
42 | esc_url( wp_mail_smtp()->get_utm_url( 'https://wpmailsmtp.com/docs/how-to-set-up-the-other-smtp-mailer-in-wp-mail-smtp/', 'Other SMTP documentation' ) )
43 | ),
44 | ],
45 | $connection
46 | );
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/Providers/Sendinblue/Api.php:
--------------------------------------------------------------------------------
1 | connection = $connection;
43 | } else {
44 | $this->connection = wp_mail_smtp()->get_connections_manager()->get_primary_connection();
45 | }
46 |
47 | $this->options = $this->connection->get_options()->get_group( Options::SLUG );
48 | }
49 |
50 | /**
51 | * Configure API key authorization: api-key.
52 | *
53 | * @since 1.6.0
54 | * @deprecated 3.9.0 We are no longer using the Sendinblue SDK.
55 | *
56 | * @return null
57 | */
58 | protected function get_api_config() {
59 |
60 | _deprecated_function( __METHOD__, '3.9.0' );
61 |
62 | return null;
63 | }
64 |
65 | /**
66 | * Get the mailer client instance for Account API.
67 | *
68 | * @since 1.6.0
69 | * @deprecated 3.9.0 We are no longer using the Sendinblue SDK.
70 | */
71 | public function get_account_client() {
72 |
73 | _deprecated_function( __METHOD__, '3.9.0' );
74 |
75 | return null;
76 | }
77 |
78 | /**
79 | * Get the mailer client instance for Sender API.
80 | *
81 | * @since 1.6.0
82 | * @deprecated 3.9.0 We are no longer using the Sendinblue SDK.
83 | */
84 | public function get_sender_client() {
85 |
86 | _deprecated_function( __METHOD__, '3.9.0' );
87 |
88 | return null;
89 | }
90 |
91 | /**
92 | * Get the mailer client instance for SMTP API.
93 | *
94 | * @since 1.6.0
95 | * @deprecated 3.9.0 We are no longer using the Sendinblue SDK.
96 | */
97 | public function get_smtp_client() {
98 |
99 | _deprecated_function( __METHOD__, '3.9.0' );
100 |
101 | return null;
102 | }
103 |
104 | /**
105 | * Whether the mailer is ready to be used in API calls.
106 | *
107 | * @since 1.6.0
108 | *
109 | * @return bool
110 | */
111 | public function is_ready() {
112 |
113 | return ! empty( $this->options['api_key'] );
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/src/Providers/Zoho/Options.php:
--------------------------------------------------------------------------------
1 | wp_mail_smtp()->assets_url . '/images/providers/zoho.svg',
24 | 'slug' => 'zoho',
25 | 'title' => esc_html__( 'Zoho Mail', 'wp-mail-smtp' ),
26 | 'disabled' => true,
27 | )
28 | );
29 | }
30 |
31 | /**
32 | * {@inheritdoc}
33 | *
34 | * @since 2.3.0
35 | */
36 | public function display_options() {
37 |
38 | ?>
39 |
44 | get_queue()->is_enabled();
45 | }
46 |
47 | /**
48 | * Initial migration - create the table structure.
49 | *
50 | * @since 4.0.0
51 | */
52 | protected function migrate_to_1() {
53 |
54 | global $wpdb;
55 |
56 | $table = Queue::get_table_name();
57 | $collate = ! empty( $wpdb->collate ) ? "COLLATE='{$wpdb->collate}'" : '';
58 |
59 | /*
60 | * Create the table.
61 | */
62 | $sql = "
63 | CREATE TABLE `$table` (
64 | `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
65 | `data` LONGTEXT NULL,
66 | `status` TINYINT UNSIGNED NOT NULL DEFAULT '0',
67 | `date_enqueued` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
68 | `date_processed` TIMESTAMP NULL,
69 | PRIMARY KEY (id),
70 | INDEX status (status),
71 | INDEX date_processed (date_processed)
72 | )
73 | ENGINE='InnoDB'
74 | {$collate};";
75 |
76 | $result = $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching
77 |
78 | if ( ! empty( $wpdb->last_error ) ) {
79 | update_option( self::ERROR_OPTION_NAME, $wpdb->last_error, false );
80 | }
81 |
82 | // Save the current version to DB.
83 | if ( $result !== false ) {
84 | $this->update_db_ver( 1 );
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/Tasks/NotificationsUpdateTask.php:
--------------------------------------------------------------------------------
1 | get_notifications()->is_enabled() ||
45 | Tasks::is_scheduled( self::ACTION ) !== false
46 | ) {
47 | return;
48 | }
49 |
50 | // Schedule the task.
51 | $this->recurring(
52 | strtotime( '+1 minute' ),
53 | wp_mail_smtp()->get_notifications()->get_notification_update_task_interval()
54 | )
55 | ->unique()
56 | ->params()
57 | ->register();
58 | }
59 |
60 | /**
61 | * Update the notification feed.
62 | *
63 | * @since 4.3.0
64 | */
65 | public function process() {
66 |
67 | // Delete task duplicates.
68 | try {
69 | $this->remove_pending( 1000 );
70 | } catch ( Exception $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
71 | // Do nothing.
72 | }
73 |
74 | wp_mail_smtp()->get_notifications()->update();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/Tasks/Queue/CleanupQueueTask.php:
--------------------------------------------------------------------------------
1 | get_queue()->is_enabled() ||
48 | Tasks::is_scheduled( self::ACTION ) !== false
49 | ) {
50 | return;
51 | }
52 |
53 | // Schedule the task.
54 | $this->recurring( strtotime( 'now' ), DAY_IN_SECONDS )
55 | ->unique()
56 | ->register();
57 | }
58 |
59 | /**
60 | * Perform email sending.
61 | *
62 | * @since 4.0.0
63 | */
64 | public function process() {
65 |
66 | $queue = wp_mail_smtp()->get_queue();
67 | $attachments = new Attachments();
68 |
69 | // Cleanup processed emails.
70 | $queue->cleanup();
71 |
72 | // Cleanup older-than-a-month attachments.
73 | $attachments->delete_attachments( null, new DateTime( '1 month ago', new DateTimeZone( 'UTC' ) ) );
74 |
75 | if ( ! $queue->is_enabled() ) {
76 | // If the query has been disabled in the meanwhile,
77 | // and there aren't any emails left,
78 | // cancel the cleanup task.
79 | $queued_emails_count = $queue->count_queued_emails();
80 | $processed_emails_count = $queue->count_processed_emails();
81 |
82 | if ( $queued_emails_count === 0 && $processed_emails_count === 0 ) {
83 | // Cleanup any remaining, older-than-an-hour attachments.
84 | $attachments->delete_attachments( null, new DateTime( '1 hour ago', new DateTimeZone( 'UTC' ) ) );
85 |
86 | $this->cancel_force();
87 | }
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/src/Tasks/Queue/ProcessQueueTask.php:
--------------------------------------------------------------------------------
1 | get_queue()->is_enabled() ||
48 | Tasks::is_scheduled( self::ACTION ) !== false
49 | ) {
50 | return;
51 | }
52 |
53 | // Schedule the task.
54 | $this->recurring( strtotime( 'now' ), MINUTE_IN_SECONDS )
55 | ->unique()
56 | ->register();
57 | }
58 |
59 | /**
60 | * Perform email sending.
61 | *
62 | * @since 4.0.0
63 | */
64 | public function process() {
65 |
66 | $queue = wp_mail_smtp()->get_queue();
67 |
68 | $queue->process();
69 |
70 | if ( ! $queue->is_enabled() ) {
71 | $this->cancel_force();
72 | }
73 | }
74 |
75 | /**
76 | * Cleanup completed tasks.
77 | *
78 | * @since 4.1.0
79 | */
80 | public function cleanup() {
81 |
82 | $this->remove_completed( 10 );
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/Tasks/Queue/SendEnqueuedEmailTask.php:
--------------------------------------------------------------------------------
1 | async()
62 | ->params( $email_id )
63 | ->register();
64 | }
65 |
66 | /**
67 | * Perform email sending.
68 | *
69 | * @since 4.0.0
70 | *
71 | * @param int $meta_id The Meta ID with the stored task parameters.
72 | */
73 | public function process( $meta_id ) {
74 |
75 | $task_meta = new Meta();
76 | $meta = $task_meta->get( (int) $meta_id );
77 |
78 | // We should actually receive the passed parameter.
79 | if ( empty( $meta ) || empty( $meta->data ) || count( $meta->data ) < 1 ) {
80 | return;
81 | }
82 |
83 | $email_id = $meta->data[0];
84 |
85 | wp_mail_smtp()->get_queue()->send_email( $email_id );
86 | }
87 |
88 | /**
89 | * Cleanup completed tasks.
90 | *
91 | * @since 4.1.0
92 | */
93 | public function cleanup() {
94 |
95 | $this->remove_completed( 10 );
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/src/Tasks/Reports/SummaryEmailTask.php:
--------------------------------------------------------------------------------
1 | recurring( $date->getTimestamp(), WEEK_IN_SECONDS )
56 | ->unique()
57 | ->register();
58 | }
59 |
60 | /**
61 | * Process summary report email send.
62 | *
63 | * @since 3.0.0
64 | *
65 | * @param int $meta_id The Meta ID with the stored task parameters.
66 | */
67 | public function process( $meta_id ) {
68 |
69 | // Prevent email sending if summary report email is disabled.
70 | if ( SummaryReportEmail::is_disabled() || ! $this->is_allowed() ) {
71 | return;
72 | }
73 |
74 | // Update the last sent week at the top to prevent multiple emails in case of task failure and retry.
75 | update_option( 'wp_mail_smtp_summary_report_email_last_sent_week', current_time( 'W' ) );
76 |
77 | $reports = wp_mail_smtp()->get_reports();
78 |
79 | $email = $reports->get_summary_report_email();
80 |
81 | $email->send();
82 | }
83 |
84 | /**
85 | * Check if the summary report email is allowed to be sent.
86 | *
87 | * The email is allowed to be sent if it was not sent in the current week.
88 | *
89 | * @since 4.1.1
90 | *
91 | * @return bool
92 | */
93 | private function is_allowed() {
94 |
95 | $last_sent_week = get_option( 'wp_mail_smtp_summary_report_email_last_sent_week' );
96 | $current_week = current_time( 'W' );
97 |
98 | if ( $last_sent_week === false || ( (int) $current_week !== (int) $last_sent_week ) ) {
99 | return true;
100 | }
101 |
102 | return false;
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/src/Upgrade.php:
--------------------------------------------------------------------------------
1 | upgrades();
28 |
29 | if ( empty( $upgrades ) ) {
30 | return;
31 | }
32 |
33 | // Run any available upgrades.
34 | foreach ( $upgrades as $upgrade ) {
35 | if ( is_callable( $upgrade ) ) {
36 | $upgrade();
37 | }
38 | }
39 |
40 | // Update version post upgrade(s).
41 | update_option( 'wp_mail_smtp_version', WPMS_PLUGIN_VER );
42 | }
43 |
44 | /**
45 | * Whether we need to perform an upgrade.
46 | *
47 | * @since 1.1.0
48 | *
49 | * @return array
50 | */
51 | protected function upgrades() {
52 |
53 | $version = get_option( 'wp_mail_smtp_version' );
54 |
55 | /**
56 | * Filters the list of upgrade callbacks to run.
57 | *
58 | * @since 4.4.0
59 | *
60 | * @param array $upgrades List of upgrade callbacks to run.
61 | * @param string $version Latest installed version of the plugin.
62 | */
63 | $upgrades = apply_filters( 'wp_mail_smtp_upgrade_upgrades', [], $version );
64 |
65 | // Version 1.1.0 upgrade; prior to this the option was not available.
66 | if ( empty( $version ) ) {
67 | $upgrades[] = [ $this, 'v110_upgrade' ];
68 | }
69 |
70 | return $upgrades;
71 | }
72 |
73 | /**
74 | * Upgrade routine for v1.1.0.
75 | *
76 | * Set SMTPAutoTLS to true.
77 | *
78 | * @since 1.1.0
79 | */
80 | public function v110_upgrade() {
81 |
82 | // Enable SMTPAutoTLS option.
83 | $values = [
84 | 'smtp' => [
85 | 'autotls' => true,
86 | ],
87 | ];
88 |
89 | Options::init()->set( $values, false, false );
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/wp-mail-smtp.php:
--------------------------------------------------------------------------------
1 |