WP Mail SMTP by WPForms - Version 1.5.1

Version Description

  • 2019-07-12 =
  • Fixed: Duplicated emails sent to the first recipient in a loop (and others not receiving their emails).
Download this release

Release Info

Developer slaFFik
Plugin Icon 128x128 WP Mail SMTP by WPForms
Version 1.5.1
Comparing to
See all releases

Code changes from version 1.5.0 to 1.5.1

assets/languages/wp-mail-smtp.pot CHANGED
@@ -7,7 +7,7 @@ msgstr ""
7
  "MIME-Version: 1.0\n"
8
  "Content-Type: text/plain; charset=UTF-8\n"
9
  "Content-Transfer-Encoding: 8bit\n"
10
- "POT-Creation-Date: 2019-07-09T13:56:27+03:00\n"
11
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12
  "X-Generator: WP-CLI 2.2.0\n"
13
  "X-Domain: wp-mail-smtp\n"
7
  "MIME-Version: 1.0\n"
8
  "Content-Type: text/plain; charset=UTF-8\n"
9
  "Content-Transfer-Encoding: 8bit\n"
10
+ "POT-Creation-Date: 2019-07-12T17:44:13+03:00\n"
11
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12
  "X-Generator: WP-CLI 2.2.0\n"
13
  "X-Domain: wp-mail-smtp\n"
loco.xml CHANGED
@@ -1,29 +1,29 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <bundle name="WP Mail SMTP">
3
- <domain name="wp-mail-smtp">
4
- <project name="WP Mail SMTP" slug="wp-mail-smtp">
5
- <source>
6
- <directory>.</directory>
7
- </source>
8
- <target>
9
- <directory>assets/languages</directory>
10
- </target>
11
- <template>
12
- <file>assets/languages/wp-mail-smtp.pot</file>
13
- </template>
14
- </project>
15
- </domain>
16
- <domain name="wp-mail-smtp-pro">
17
- <project name="WP Mail SMTP Pro" slug="wp-mail-smtp-pro">
18
- <source>
19
- <directory>.</directory>
20
- </source>
21
- <target>
22
- <directory>assets/pro/languages</directory>
23
- </target>
24
- <template>
25
- <file>assets/pro/languages/wp-mail-smtp-pro.pot</file>
26
- </template>
27
- </project>
28
- </domain>
29
- </bundle>
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <bundle name="WP Mail SMTP">
3
+ <domain name="wp-mail-smtp">
4
+ <project name="WP Mail SMTP" slug="wp-mail-smtp">
5
+ <source>
6
+ <directory>.</directory>
7
+ </source>
8
+ <target>
9
+ <directory>assets/languages</directory>
10
+ </target>
11
+ <template>
12
+ <file>assets/languages/wp-mail-smtp.pot</file>
13
+ </template>
14
+ </project>
15
+ </domain>
16
+ <domain name="wp-mail-smtp-pro">
17
+ <project name="WP Mail SMTP Pro" slug="wp-mail-smtp-pro">
18
+ <source>
19
+ <directory>.</directory>
20
+ </source>
21
+ <target>
22
+ <directory>assets/pro/languages</directory>
23
+ </target>
24
+ <template>
25
+ <file>assets/pro/languages/wp-mail-smtp-pro.pot</file>
26
+ </template>
27
+ </project>
28
+ </domain>
29
+ </bundle>
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: wpforms, jaredatch, smub, slaFFik
3
  Tags: smtp, wp mail smtp, wordpress smtp, gmail smtp, sendgrid smtp, mailgun smtp, mail, mailer, phpmailer, wp_mail, email, mailgun, sengrid, gmail, wp smtp
4
  Requires at least: 4.9
5
  Tested up to: 5.2
6
- Stable tag: 1.5.0
7
  Requires PHP: 5.3
8
 
9
  The most popular WordPress SMTP and PHP Mailer plugin. Trusted by over 1 million sites.
@@ -195,6 +195,9 @@ By all means please contact us to discuss features or options you'd like to see
195
 
196
  == Changelog ==
197
 
 
 
 
198
  = 1.5.0 - 2019-07-09 =
199
  * Added: Loсo plugin support.
200
  * Added: "About us" admin area page.
@@ -447,47 +450,3 @@ By all means please contact us to discuss features or options you'd like to see
447
 
448
  = 0.1 =
449
  * Initial approach, copying the wp_mail function and replacing it
450
-
451
- == Upgrade Notice ==
452
-
453
- = 0.10.1 =
454
- Addition of Pepipost and cleanup of admin page.
455
-
456
- = 0.10.0 =
457
- Addition of Pepipost and cleanup of admin page.
458
-
459
- = 0.9.6 =
460
- Minor security fix, sanitize test email address.
461
-
462
- = 0.9.5 =
463
- Minor security fix, hat tip JD Grimes.
464
-
465
- = 0.9.4 =
466
- Improvement to the test email function, very low priority update.
467
-
468
- = 0.9.3 =
469
- Fixing reported issue with passing by reference.
470
-
471
- = 0.9.2 =
472
- Removing the deprecation notice.
473
-
474
- = 0.9.1 =
475
- Test mail functionality was broken on upgrade to 3.2, now restored.
476
-
477
- = 0.9.0 =
478
- Low priority upgrade. Improves the appearance of the options page.
479
-
480
- = 0.8.7 =
481
- Very low priority update. Fixes a bug that causes a spurious error during activation.
482
-
483
- = 0.8.6 =
484
- Low priority update. The Settings link was still broken in 0.8.5.
485
-
486
- = 0.8.5 =
487
- Minor bugfix correcting the Settings link bug introduced in 0.8.4. Very low priority update.
488
-
489
- = 0.8.4 =
490
- Minor bugfix for users using constants. Another very low priority upgrade. Apologies for the version creep.
491
-
492
- = 0.8.3 =
493
- Minor bugfix for users using constants. Very low priority upgrade.
3
  Tags: smtp, wp mail smtp, wordpress smtp, gmail smtp, sendgrid smtp, mailgun smtp, mail, mailer, phpmailer, wp_mail, email, mailgun, sengrid, gmail, wp smtp
4
  Requires at least: 4.9
5
  Tested up to: 5.2
6
+ Stable tag: 1.5.1
7
  Requires PHP: 5.3
8
 
9
  The most popular WordPress SMTP and PHP Mailer plugin. Trusted by over 1 million sites.
195
 
196
  == Changelog ==
197
 
198
+ = 1.5.1 - 2019-07-12 =
199
+ * Fixed: Duplicated emails sent to the first recipient in a loop (and others not receiving their emails).
200
+
201
  = 1.5.0 - 2019-07-09 =
202
  * Added: Loсo plugin support.
203
  * Added: "About us" admin area page.
450
 
451
  = 0.1 =
452
  * Initial approach, copying the wp_mail function and replacing it
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/Admin/Pages/About.php CHANGED
@@ -578,7 +578,7 @@ class About extends PageAbstract {
578
  <div class="wp-mail-smtp-admin-about-section wp-mail-smtp-admin-about-section-hero">
579
  <div class="wp-mail-smtp-admin-about-section-hero-main no-border">
580
  <h3 class="call-to-action centered">
581
- <a href="https://wpmailsmtp.com/pricing?utm_source=WordPress&utm_medium=about-page&utm_campaign=smtpplugin&discount=LITEUPGRADE" target="_blank" rel="noopener noreferrer">
582
  <?php \esc_html_e( 'Get WP Mail SMTP Pro Today and Unlock all of these Powerful Features', 'wp-mail-smtp' ); ?>
583
  </a>
584
  </h3>
578
  <div class="wp-mail-smtp-admin-about-section wp-mail-smtp-admin-about-section-hero">
579
  <div class="wp-mail-smtp-admin-about-section-hero-main no-border">
580
  <h3 class="call-to-action centered">
581
+ <a href="<?php echo esc_url( wp_mail_smtp()->get_upgrade_link( 'lite-vs-pro' ) ); ?>" target="_blank" rel="noopener noreferrer">
582
  <?php \esc_html_e( 'Get WP Mail SMTP Pro Today and Unlock all of these Powerful Features', 'wp-mail-smtp' ); ?>
583
  </a>
584
  </h3>
src/Admin/Pages/Settings.php CHANGED
@@ -290,7 +290,7 @@ class Settings extends PageAbstract {
290
  'strong' => array(),
291
  )
292
  ),
293
- esc_url( wp_mail_smtp()->get_upgrade_link( 'settings-license' ) )
294
  );
295
  ?>
296
  </p>
@@ -405,7 +405,7 @@ class Settings extends PageAbstract {
405
  'strong' => array(),
406
  )
407
  ),
408
- 'https://wpmailsmtp.com/pricing-lite/?utm_source=WordPress&utm_medium=settings-cta&utm_campaign=plugin'
409
  );
410
  ?>
411
  </p>
290
  'strong' => array(),
291
  )
292
  ),
293
+ esc_url( wp_mail_smtp()->get_upgrade_link( 'general-license-key' ) )
294
  );
295
  ?>
296
  </p>
405
  'strong' => array(),
406
  )
407
  ),
408
+ esc_url( wp_mail_smtp()->get_upgrade_link( 'general-cta' ) )
409
  );
410
  ?>
411
  </p>
src/Admin/Pages/Test.php CHANGED
@@ -320,7 +320,7 @@ class Test extends PageAbstract {
320
  <table style="border-collapse: collapse; border-spacing: 0; padding: 0; vertical-align: top; text-align: left; mso-table-lspace: 0pt; mso-table-rspace: 0pt; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; width: 100% !important;">
321
  <tr style="padding: 0; vertical-align: top; text-align: left;">
322
  <td style="word-wrap: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; border-collapse: collapse !important; vertical-align: top; mso-table-lspace: 0pt; mso-table-rspace: 0pt; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; font-weight: normal; padding: 0; margin: 0; Margin: 0; font-size: 14px; text-align: center; color: #ffffff; background: #e27730; border: 1px solid #c45e1b; border-bottom: 3px solid #c45e1b; mso-line-height-rule: exactly; line-height: 100%;">
323
- <a href="https://wpmailsmtp.com/pricing-lite/?utm_source=WordPress&utm_medium=email-cta&utm_campaign=plugin" style="-ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; margin: 0; Margin: 0; font-family: Helvetica, Arial, sans-serif; font-weight: bold; color: #ffffff; text-decoration: none; display: inline-block; border: 0 solid #c45e1b; mso-line-height-rule: exactly; line-height: 100%; padding: 14px 20px 12px 20px; font-size: 20px; text-align: center; width: 100%; padding-left: 0; padding-right: 0;">
324
  Upgrade to WP Mail SMTP Pro Today
325
  </a>
326
  </td>
@@ -1066,7 +1066,7 @@ Lead Developer, WP Mail SMTP';
1066
  ),
1067
  )
1068
  ),
1069
- 'https://wpmailsmtp.com/pricing-lite/?utm_source=WordPress&utm_medium=debug-cta&utm_campaign=plugin'
1070
  )
1071
  ?>
1072
  </p>
@@ -1103,7 +1103,7 @@ Lead Developer, WP Mail SMTP';
1103
  ),
1104
  'https://wordpress.org/support/topic/wp-mail-smtp-support-policy/',
1105
  'https://wordpress.org/support/plugin/wp-mail-smtp/',
1106
- 'https://wpmailsmtp.com/pricing-lite/?utm_source=WordPress&utm_medium=debug-cta&utm_campaign=plugin'
1107
  );
1108
  ?>
1109
  </p>
320
  <table style="border-collapse: collapse; border-spacing: 0; padding: 0; vertical-align: top; text-align: left; mso-table-lspace: 0pt; mso-table-rspace: 0pt; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; width: 100% !important;">
321
  <tr style="padding: 0; vertical-align: top; text-align: left;">
322
  <td style="word-wrap: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; border-collapse: collapse !important; vertical-align: top; mso-table-lspace: 0pt; mso-table-rspace: 0pt; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; font-weight: normal; padding: 0; margin: 0; Margin: 0; font-size: 14px; text-align: center; color: #ffffff; background: #e27730; border: 1px solid #c45e1b; border-bottom: 3px solid #c45e1b; mso-line-height-rule: exactly; line-height: 100%;">
323
+ <a href="<?php echo esc_url( wp_mail_smtp()->get_upgrade_link( 'email-test' ) ); ?>" style="-ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; margin: 0; Margin: 0; font-family: Helvetica, Arial, sans-serif; font-weight: bold; color: #ffffff; text-decoration: none; display: inline-block; border: 0 solid #c45e1b; mso-line-height-rule: exactly; line-height: 100%; padding: 14px 20px 12px 20px; font-size: 20px; text-align: center; width: 100%; padding-left: 0; padding-right: 0;">
324
  Upgrade to WP Mail SMTP Pro Today
325
  </a>
326
  </td>
1066
  ),
1067
  )
1068
  ),
1069
+ esc_url( wp_mail_smtp()->get_upgrade_link( 'email-test-fail' ) )
1070
  )
1071
  ?>
1072
  </p>
1103
  ),
1104
  'https://wordpress.org/support/topic/wp-mail-smtp-support-policy/',
1105
  'https://wordpress.org/support/plugin/wp-mail-smtp/',
1106
+ esc_url( wp_mail_smtp()->get_upgrade_link( 'email-test-fail' ) )
1107
  );
1108
  ?>
1109
  </p>
src/Core.php CHANGED
@@ -547,9 +547,10 @@ class Core {
547
  }
548
 
549
  /**
550
- * Overwrite default PhpMailer with out MailCatcher.
551
  *
552
  * @since 1.0.0
 
553
  *
554
  * @param null $obj PhpMailer object to override with own implementation.
555
  *
@@ -635,13 +636,40 @@ class Core {
635
  * Upgrade link used within the various admin pages.
636
  *
637
  * @since 1.5.0
 
638
  *
639
- * @param string $medium utm_medium URL parameter.
640
  *
641
- * @return string.
642
  */
643
- public function get_upgrade_link( $medium = 'link' ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
644
 
645
- return apply_filters( 'wp_mail_smtp_core_get_upgrade_link', 'https://wpmailsmtp.com/lite-upgrade/?discount=LITEUPGRADE&amp;utm_source=WordPress&amp;utm_medium=' . sanitize_key( apply_filters( 'wp_mail_smtp_core_get_upgrade_link_medium', $medium ) ) . '&amp;utm_campaign=liteplugin' );
 
 
 
646
  }
647
  }
547
  }
548
 
549
  /**
550
+ * Overwrite default PhpMailer with our MailCatcher.
551
  *
552
  * @since 1.0.0
553
+ * @since 1.5.0 Throw external PhpMailer exceptions, inherits default WP behavior.
554
  *
555
  * @param null $obj PhpMailer object to override with own implementation.
556
  *
636
  * Upgrade link used within the various admin pages.
637
  *
638
  * @since 1.5.0
639
+ * @since 1.5.1 Support all UTM params.
640
  *
641
+ * @param array|string $utm Array of UTM params, or if string provided - utm_content URL parameter.
642
  *
643
+ * @return string
644
  */
645
+ public function get_upgrade_link( $utm ) {
646
+
647
+ // Defaults.
648
+ $source = 'WordPress';
649
+ $medium = 'plugin-settings';
650
+ $campaign = 'liteplugin';
651
+ $content = 'general';
652
+
653
+ if ( is_array( $utm ) ) {
654
+ if ( isset( $utm['source'] ) ) {
655
+ $source = $utm['source'];
656
+ }
657
+ if ( isset( $utm['medium'] ) ) {
658
+ $medium = $utm['medium'];
659
+ }
660
+ if ( isset( $utm['campaign'] ) ) {
661
+ $campaign = $utm['campaign'];
662
+ }
663
+ if ( isset( $utm['content'] ) ) {
664
+ $content = $utm['content'];
665
+ }
666
+ } elseif ( is_string( $utm ) ) {
667
+ $content = $utm;
668
+ }
669
 
670
+ return apply_filters(
671
+ 'wp_mail_smtp_core_get_upgrade_link',
672
+ 'https://wpmailsmtp.com/lite-upgrade/?utm_source=' . esc_attr( $source ) . '&utm_medium=' . esc_attr( $medium ) . '&utm_campaign=' . esc_attr( $campaign ) . '&utm_content=' . esc_attr( $content )
673
+ );
674
  }
675
  }
src/Geo.php CHANGED
@@ -1,143 +1,143 @@
1
- <?php
2
-
3
- namespace WPMailSMTP;
4
-
5
- /**
6
- * Class Geo to work with location, domain, IPs etc.
7
- *
8
- * @since 1.5.0
9
- */
10
- class Geo {
11
-
12
- /**
13
- * Get the current site hostname.
14
- * Examples: example.com, localhost.
15
- *
16
- * @since 1.5.0
17
- *
18
- * @return string
19
- */
20
- public static function get_site_domain() {
21
-
22
- return ! empty( $_SERVER['SERVER_NAME'] ) ? $_SERVER['SERVER_NAME'] : wp_parse_url( get_home_url( get_current_blog_id() ), PHP_URL_HOST );
23
- }
24
-
25
- /**
26
- * Get the domain IP address.
27
- * Uses gethostbyname() which is quite slow, but this is done only one time.
28
- *
29
- * @since 1.5.0
30
- *
31
- * @param string $domain
32
- *
33
- * @return string
34
- */
35
- public static function get_ip_by_domain( $domain ) {
36
-
37
- if ( $domain === 'localhost' ) {
38
- return '127.0.0.1';
39
- }
40
-
41
- return gethostbyname( $domain );
42
- }
43
-
44
- /**
45
- * Get the location coordinates by IP address.
46
- * We make a request to 3rd party services.
47
- *
48
- * @since 1.5.0
49
- *
50
- * @param string $ip
51
- *
52
- * @return array Empty array for localhost.
53
- */
54
- public static function get_location_by_ip( $ip ) {
55
-
56
- // Check for a non-local IP.
57
- if ( empty( $ip ) || in_array( $ip, array( '127.0.0.1', '::1' ), true ) ) {
58
- return array();
59
- }
60
-
61
- $request = wp_remote_get( 'https://ipapi.co/' . $ip . '/json' );
62
-
63
- if ( ! is_wp_error( $request ) ) {
64
-
65
- $request = json_decode( wp_remote_retrieve_body( $request ), true );
66
-
67
- if ( ! empty( $request['latitude'] ) && ! empty( $request['longitude'] ) ) {
68
-
69
- $data = array(
70
- 'latitude' => sanitize_text_field( $request['latitude'] ),
71
- 'longitude' => sanitize_text_field( $request['longitude'] ),
72
- 'city' => sanitize_text_field( $request['city'] ),
73
- 'region' => sanitize_text_field( $request['region'] ),
74
- 'country' => sanitize_text_field( $request['country'] ),
75
- 'postal' => sanitize_text_field( $request['postal'] ),
76
- );
77
-
78
- return $data;
79
- }
80
- }
81
-
82
- $request = wp_remote_get( 'https://tools.keycdn.com/geo.json?host=' . $ip );
83
-
84
- if ( ! is_wp_error( $request ) ) {
85
-
86
- $request = json_decode( wp_remote_retrieve_body( $request ), true );
87
-
88
- if ( ! empty( $request['data']['geo']['latitude'] ) && ! empty( $request['data']['geo']['longitude'] ) ) {
89
-
90
- $data = array(
91
- 'latitude' => sanitize_text_field( $request['data']['geo']['latitude'] ),
92
- 'longitude' => sanitize_text_field( $request['data']['geo']['longitude'] ),
93
- 'city' => sanitize_text_field( $request['data']['geo']['city'] ),
94
- 'region' => sanitize_text_field( $request['data']['geo']['region_name'] ),
95
- 'country' => sanitize_text_field( $request['data']['geo']['country_code'] ),
96
- 'postal' => sanitize_text_field( $request['data']['geo']['postal_code'] ),
97
- );
98
-
99
- return $data;
100
- }
101
- }
102
-
103
- return array();
104
- }
105
-
106
- /**
107
- * This routine calculates the distance between two points (given the latitude/longitude of those points).
108
- * Definitions: South latitudes are negative, east longitudes are positive.
109
- *
110
- * @see https://www.geodatasource.com/developers/php
111
- *
112
- * @since 1.5.0
113
- *
114
- * @param float $lat1 Latitude of point 1 (in decimal degrees).
115
- * @param float $lon1 Longitude of point 1 (in decimal degrees).
116
- * @param float $lat2 Latitude of point 2 (in decimal degrees).
117
- * @param float $lon2 Longitude of point 2 (in decimal degrees).
118
- * @param string $unit Supported values: M, K, N. Miles by default.
119
- *
120
- * @return float|int
121
- */
122
- public static function get_distance_between( $lat1, $lon1, $lat2, $lon2, $unit = 'M' ) {
123
-
124
- if ( ( $lat1 === $lat2 ) && ( $lon1 === $lon2 ) ) {
125
- return 0;
126
- }
127
-
128
- $theta = $lon1 - $lon2;
129
- $dist = sin( deg2rad( $lat1 ) ) * sin( deg2rad( $lat2 ) ) + cos( deg2rad( $lat1 ) ) * cos( deg2rad( $lat2 ) ) * cos( deg2rad( $theta ) );
130
- $dist = acos( $dist );
131
- $dist = rad2deg( $dist );
132
- $miles = $dist * 60 * 1.1515;
133
- $unit = strtoupper( $unit );
134
-
135
- if ( $unit === 'K' ) {
136
- return ( $miles * 1.609344 );
137
- } elseif ( $unit === 'N' ) {
138
- return ( $miles * 0.8684 );
139
- }
140
-
141
- return $miles;
142
- }
143
- }
1
+ <?php
2
+
3
+ namespace WPMailSMTP;
4
+
5
+ /**
6
+ * Class Geo to work with location, domain, IPs etc.
7
+ *
8
+ * @since 1.5.0
9
+ */
10
+ class Geo {
11
+
12
+ /**
13
+ * Get the current site hostname.
14
+ * Examples: example.com, localhost.
15
+ *
16
+ * @since 1.5.0
17
+ *
18
+ * @return string
19
+ */
20
+ public static function get_site_domain() {
21
+
22
+ return ! empty( $_SERVER['SERVER_NAME'] ) ? $_SERVER['SERVER_NAME'] : wp_parse_url( get_home_url( get_current_blog_id() ), PHP_URL_HOST );
23
+ }
24
+
25
+ /**
26
+ * Get the domain IP address.
27
+ * Uses gethostbyname() which is quite slow, but this is done only one time.
28
+ *
29
+ * @since 1.5.0
30
+ *
31
+ * @param string $domain
32
+ *
33
+ * @return string
34
+ */
35
+ public static function get_ip_by_domain( $domain ) {
36
+
37
+ if ( $domain === 'localhost' ) {
38
+ return '127.0.0.1';
39
+ }
40
+
41
+ return gethostbyname( $domain );
42
+ }
43
+
44
+ /**
45
+ * Get the location coordinates by IP address.
46
+ * We make a request to 3rd party services.
47
+ *
48
+ * @since 1.5.0
49
+ *
50
+ * @param string $ip
51
+ *
52
+ * @return array Empty array for localhost.
53
+ */
54
+ public static function get_location_by_ip( $ip ) {
55
+
56
+ // Check for a non-local IP.
57
+ if ( empty( $ip ) || in_array( $ip, array( '127.0.0.1', '::1' ), true ) ) {
58
+ return array();
59
+ }
60
+
61
+ $request = wp_remote_get( 'https://ipapi.co/' . $ip . '/json' );
62
+
63
+ if ( ! is_wp_error( $request ) ) {
64
+
65
+ $request = json_decode( wp_remote_retrieve_body( $request ), true );
66
+
67
+ if ( ! empty( $request['latitude'] ) && ! empty( $request['longitude'] ) ) {
68
+
69
+ $data = array(
70
+ 'latitude' => sanitize_text_field( $request['latitude'] ),
71
+ 'longitude' => sanitize_text_field( $request['longitude'] ),
72
+ 'city' => sanitize_text_field( $request['city'] ),
73
+ 'region' => sanitize_text_field( $request['region'] ),
74
+ 'country' => sanitize_text_field( $request['country'] ),
75
+ 'postal' => sanitize_text_field( $request['postal'] ),
76
+ );
77
+
78
+ return $data;
79
+ }
80
+ }
81
+
82
+ $request = wp_remote_get( 'https://tools.keycdn.com/geo.json?host=' . $ip );
83
+
84
+ if ( ! is_wp_error( $request ) ) {
85
+
86
+ $request = json_decode( wp_remote_retrieve_body( $request ), true );
87
+
88
+ if ( ! empty( $request['data']['geo']['latitude'] ) && ! empty( $request['data']['geo']['longitude'] ) ) {
89
+
90
+ $data = array(
91
+ 'latitude' => sanitize_text_field( $request['data']['geo']['latitude'] ),
92
+ 'longitude' => sanitize_text_field( $request['data']['geo']['longitude'] ),
93
+ 'city' => sanitize_text_field( $request['data']['geo']['city'] ),
94
+ 'region' => sanitize_text_field( $request['data']['geo']['region_name'] ),
95
+ 'country' => sanitize_text_field( $request['data']['geo']['country_code'] ),
96
+ 'postal' => sanitize_text_field( $request['data']['geo']['postal_code'] ),
97
+ );
98
+
99
+ return $data;
100
+ }
101
+ }
102
+
103
+ return array();
104
+ }
105
+
106
+ /**
107
+ * This routine calculates the distance between two points (given the latitude/longitude of those points).
108
+ * Definitions: South latitudes are negative, east longitudes are positive.
109
+ *
110
+ * @see https://www.geodatasource.com/developers/php
111
+ *
112
+ * @since 1.5.0
113
+ *
114
+ * @param float $lat1 Latitude of point 1 (in decimal degrees).
115
+ * @param float $lon1 Longitude of point 1 (in decimal degrees).
116
+ * @param float $lat2 Latitude of point 2 (in decimal degrees).
117
+ * @param float $lon2 Longitude of point 2 (in decimal degrees).
118
+ * @param string $unit Supported values: M, K, N. Miles by default.
119
+ *
120
+ * @return float|int
121
+ */
122
+ public static function get_distance_between( $lat1, $lon1, $lat2, $lon2, $unit = 'M' ) {
123
+
124
+ if ( ( $lat1 === $lat2 ) && ( $lon1 === $lon2 ) ) {
125
+ return 0;
126
+ }
127
+
128
+ $theta = $lon1 - $lon2;
129
+ $dist = sin( deg2rad( $lat1 ) ) * sin( deg2rad( $lat2 ) ) + cos( deg2rad( $lat1 ) ) * cos( deg2rad( $lat2 ) ) * cos( deg2rad( $theta ) );
130
+ $dist = acos( $dist );
131
+ $dist = rad2deg( $dist );
132
+ $miles = $dist * 60 * 1.1515;
133
+ $unit = strtoupper( $unit );
134
+
135
+ if ( $unit === 'K' ) {
136
+ return ( $miles * 1.609344 );
137
+ } elseif ( $unit === 'N' ) {
138
+ return ( $miles * 0.8684 );
139
+ }
140
+
141
+ return $miles;
142
+ }
143
+ }
src/Providers/Loader.php CHANGED
@@ -78,7 +78,6 @@ class Loader {
78
  * Get the provider options, if exists.
79
  *
80
  * @since 1.0.0
81
- * @since 1.5.0 Init the Option class for a provider only once and store it for future reuse.
82
  *
83
  * @param string $provider
84
  *
@@ -86,13 +85,7 @@ class Loader {
86
  */
87
  public function get_options( $provider ) {
88
 
89
- static $options = array();
90
-
91
- if ( empty( $options[ $provider ] ) ) {
92
- $options[ $provider ] = $this->get_entity( $provider, 'Options' );
93
- }
94
-
95
- return $options[ $provider ];
96
  }
97
 
98
  /**
@@ -131,7 +124,6 @@ class Loader {
131
  * Get the provider mailer, if exists.
132
  *
133
  * @since 1.0.0
134
- * @since 1.5.0 Init the Mailer class for a provider only once and store it for future reuse.
135
  *
136
  * @param string $provider
137
  * @param MailCatcher $phpmailer
@@ -140,8 +132,6 @@ class Loader {
140
  */
141
  public function get_mailer( $provider, $phpmailer ) {
142
 
143
- static $providers = array();
144
-
145
  if (
146
  $phpmailer instanceof MailCatcher ||
147
  $phpmailer instanceof \PHPMailer
@@ -149,11 +139,7 @@ class Loader {
149
  $this->phpmailer = $phpmailer;
150
  }
151
 
152
- if ( empty( $providers[ $provider ] ) ) {
153
- $providers[ $provider ] = $this->get_entity( $provider, 'Mailer' );
154
- }
155
-
156
- return $providers[ $provider ];
157
  }
158
 
159
  /**
78
  * Get the provider options, if exists.
79
  *
80
  * @since 1.0.0
 
81
  *
82
  * @param string $provider
83
  *
85
  */
86
  public function get_options( $provider ) {
87
 
88
+ return $this->get_entity( $provider, 'Options' );
 
 
 
 
 
 
89
  }
90
 
91
  /**
124
  * Get the provider mailer, if exists.
125
  *
126
  * @since 1.0.0
 
127
  *
128
  * @param string $provider
129
  * @param MailCatcher $phpmailer
132
  */
133
  public function get_mailer( $provider, $phpmailer ) {
134
 
 
 
135
  if (
136
  $phpmailer instanceof MailCatcher ||
137
  $phpmailer instanceof \PHPMailer
139
  $this->phpmailer = $phpmailer;
140
  }
141
 
142
+ return $this->get_entity( $provider, 'Mailer' );
 
 
 
 
143
  }
144
 
145
  /**
wp-mail-smtp-0.11.2.php CHANGED
@@ -1,802 +1,802 @@
1
- <?php
2
- /**
3
- * This is an obsolete version of the plugin, as of 0.11.2 released on 2017-11-28.
4
- * This code is loaded only when the site runs on PHP 5.2.
5
- */
6
-
7
- /**
8
- * Array of options and their default values.
9
- * This is horrible, should be cleaned up at some point.
10
- */
11
- global $wpms_options;
12
- $wpms_options = array(
13
- 'mail_from' => '',
14
- 'mail_from_name' => '',
15
- 'mailer' => 'smtp',
16
- 'mail_set_return_path' => 'false',
17
- 'smtp_host' => 'localhost',
18
- 'smtp_port' => '25',
19
- 'smtp_ssl' => 'none',
20
- 'smtp_auth' => false,
21
- 'smtp_user' => '',
22
- 'smtp_pass' => '',
23
- 'pepipost_user' => '',
24
- 'pepipost_pass' => '',
25
- 'pepipost_port' => '2525',
26
- 'pepipost_ssl' => 'none',
27
- 'wp_mail_smtp_am_notifications_hidden' => '',
28
- );
29
-
30
- /**
31
- * Activation function. This function creates the required options and defaults.
32
- */
33
- if ( ! function_exists( 'wp_mail_smtp_activate' ) ) :
34
- /**
35
- * What to do on plugin activation.
36
- */
37
- function wp_mail_smtp_activate() {
38
-
39
- global $wpms_options;
40
-
41
- // Create the required options...
42
- foreach ( $wpms_options as $name => $val ) {
43
- add_option( $name, $val );
44
- }
45
- }
46
- endif;
47
-
48
- if ( ! function_exists( 'wp_mail_smtp_whitelist_options' ) ) :
49
- /**
50
- * Whitelist plugin options.
51
- *
52
- * @param array $whitelist_options
53
- *
54
- * @return mixed
55
- */
56
- function wp_mail_smtp_whitelist_options( $whitelist_options ) {
57
-
58
- global $wpms_options;
59
-
60
- // Add our options to the array.
61
- $whitelist_options['email'] = array_keys( $wpms_options );
62
-
63
- return $whitelist_options;
64
- }
65
- endif;
66
-
67
- /**
68
- * To avoid any (very unlikely) clashes, check if the function already exists.
69
- */
70
- if ( ! function_exists( 'phpmailer_init_smtp' ) ) :
71
- /**
72
- * This code is copied, from wp-includes/pluggable.php as at version 2.2.2.
73
- *
74
- * @param PHPMailer $phpmailer It's passed by reference, so no need to return anything.
75
- */
76
- function phpmailer_init_smtp( $phpmailer ) {
77
- /*
78
- * If constants are defined, apply them.
79
- * We should have defined all required constants before using them.
80
- */
81
- if (
82
- defined( 'WPMS_ON' ) && WPMS_ON &&
83
- defined( 'WPMS_MAILER' )
84
- ) {
85
- $phpmailer->Mailer = WPMS_MAILER;
86
-
87
- if ( defined( 'WPMS_SET_RETURN_PATH' ) && WPMS_SET_RETURN_PATH ) {
88
- $phpmailer->Sender = $phpmailer->From;
89
- }
90
-
91
- if (
92
- WPMS_MAILER === 'smtp' &&
93
- defined( 'WPMS_SSL' ) &&
94
- defined( 'WPMS_SMTP_HOST' ) &&
95
- defined( 'WPMS_SMTP_PORT' )
96
- ) {
97
- $phpmailer->SMTPSecure = WPMS_SSL;
98
- $phpmailer->Host = WPMS_SMTP_HOST;
99
- $phpmailer->Port = WPMS_SMTP_PORT;
100
-
101
- if (
102
- defined( 'WPMS_SMTP_AUTH' ) && WPMS_SMTP_AUTH &&
103
- defined( 'WPMS_SMTP_USER' ) &&
104
- defined( 'WPMS_SMTP_PASS' )
105
- ) {
106
- $phpmailer->SMTPAuth = true;
107
- $phpmailer->Username = WPMS_SMTP_USER;
108
- $phpmailer->Password = WPMS_SMTP_PASS;
109
- }
110
- }
111
- } else {
112
- $option_mailer = get_option( 'mailer' );
113
- $option_smtp_host = get_option( 'smtp_host' );
114
- $option_smtp_ssl = get_option( 'smtp_ssl' );
115
-
116
- // Check that mailer is not blank, and if mailer=smtp, host is not blank.
117
- if (
118
- ! $option_mailer ||
119
- ( 'smtp' === $option_mailer && ! $option_smtp_host )
120
- ) {
121
- return;
122
- }
123
-
124
- // If the mailer is pepipost, make sure we have a username and password.
125
- if ( 'pepipost' === $option_mailer && ( ! get_option( 'pepipost_user' ) && ! get_option( 'pepipost_pass' ) ) ) {
126
- return;
127
- }
128
-
129
- // Set the mailer type as per config above, this overrides the already called isMail method.
130
- $phpmailer->Mailer = $option_mailer;
131
-
132
- // Set the Sender (return-path) if required.
133
- if ( get_option( 'mail_set_return_path' ) ) {
134
- $phpmailer->Sender = $phpmailer->From;
135
- }
136
-
137
- // Set the SMTPSecure value, if set to none, leave this blank.
138
- $phpmailer->SMTPSecure = $option_smtp_ssl;
139
- if ( 'none' === $option_smtp_ssl ) {
140
- $phpmailer->SMTPSecure = '';
141
- $phpmailer->SMTPAutoTLS = false;
142
- }
143
-
144
- // If we're sending via SMTP, set the host.
145
- if ( 'smtp' === $option_mailer ) {
146
- // Set the other options.
147
- $phpmailer->Host = $option_smtp_host;
148
- $phpmailer->Port = get_option( 'smtp_port' );
149
-
150
- // If we're using smtp auth, set the username & password.
151
- if ( get_option( 'smtp_auth' ) === 'true' ) {
152
- $phpmailer->SMTPAuth = true;
153
- $phpmailer->Username = get_option( 'smtp_user' );
154
- $phpmailer->Password = get_option( 'smtp_pass' );
155
- }
156
- } elseif ( 'pepipost' === $option_mailer ) {
157
- // Set the Pepipost settings.
158
- $phpmailer->Mailer = 'smtp';
159
- $phpmailer->Host = 'smtp.pepipost.com';
160
- $phpmailer->Port = get_option( 'pepipost_port' );
161
- $phpmailer->SMTPSecure = get_option( 'pepipost_ssl' ) === 'none' ? '' : get_option( 'pepipost_ssl' );
162
- $phpmailer->SMTPAuth = true;
163
- $phpmailer->Username = get_option( 'pepipost_user' );
164
- $phpmailer->Password = get_option( 'pepipost_pass' );
165
- }
166
- }
167
-
168
- // You can add your own options here, see the phpmailer documentation for more info: http://phpmailer.sourceforge.net/docs/.
169
- /** @noinspection PhpUnusedLocalVariableInspection It's passed by reference. */
170
- $phpmailer = apply_filters( 'wp_mail_smtp_custom_options', $phpmailer );
171
- }
172
- endif;
173
-
174
- if ( ! function_exists( 'wp_mail_smtp_options_page' ) ) :
175
- /**
176
- * This function outputs the plugin options page.
177
- */
178
- function wp_mail_smtp_options_page() {
179
-
180
- global $phpmailer;
181
-
182
- // Make sure the PHPMailer class has been instantiated
183
- // (copied verbatim from wp-includes/pluggable.php)
184
- // (Re)create it, if it's gone missing.
185
- if ( ! is_object( $phpmailer ) || ! is_a( $phpmailer, 'PHPMailer' ) ) {
186
- require_once ABSPATH . WPINC . '/class-phpmailer.php';
187
- $phpmailer = new PHPMailer( true );
188
- }
189
-
190
- // Send a test mail if necessary.
191
- if (
192
- isset( $_POST['wpms_action'] ) &&
193
- esc_html__( 'Send Test', 'wp-mail-smtp' ) === sanitize_text_field( $_POST['wpms_action'] ) &&
194
- is_email( $_POST['to'] )
195
- ) {
196
-
197
- check_admin_referer( 'test-email' );
198
-
199
- // Set up the mail variables.
200
- $to = sanitize_text_field( $_POST['to'] );
201
- /* translators: %s - email address where test mail will be sent to. */
202
- $subject = 'WP Mail SMTP: ' . sprintf( esc_html__( 'Test mail to %s', 'wp-mail-smtp' ), $to );
203
- $message = esc_html__( 'This is a test email generated by the WP Mail SMTP WordPress plugin.', 'wp-mail-smtp' );
204
-
205
- // Set SMTPDebug level, default is 2 (commands + data + connection status).
206
- $phpmailer->SMTPDebug = apply_filters( 'wp_mail_smtp_admin_test_email_smtp_debug', 2 );
207
-
208
- // Start output buffering to grab smtp debugging output.
209
- ob_start();
210
-
211
- // Send the test mail.
212
- $result = wp_mail( $to, $subject, $message );
213
-
214
- // Grab the smtp debugging output.
215
- $smtp_debug = ob_get_clean();
216
-
217
- // Output the response.
218
- ?>
219
- <div id="message" class="updated notice is-dismissible"><p><strong><?php esc_html_e( 'Test Message Sent', 'wp-mail-smtp' ); ?></strong></p>
220
- <p><?php esc_html_e( 'The result was:', 'wp-mail-smtp' ); ?></p>
221
- <pre><?php var_dump( $result ); ?></pre>
222
-
223
- <p><?php esc_html_e( 'The full debugging output is shown below:', 'wp-mail-smtp' ); ?></p>
224
- <pre><?php print_r( $phpmailer ); ?></pre>
225
-
226
- <p><?php esc_html_e( 'The SMTP debugging output is shown below:', 'wp-mail-smtp' ); ?></p>
227
- <pre><?php echo $smtp_debug; ?></pre>
228
- </div>
229
- <?php
230
-
231
- // Destroy $phpmailer so it doesn't cause issues later.
232
- unset( $phpmailer );
233
- }
234
-
235
- ?>
236
- <div class="wrap">
237
- <h2>
238
- <?php esc_html_e( 'WP Mail SMTP Settings', 'wp-mail-smtp' ); ?>
239
- </h2>
240
-
241
- <form method="post" action="<?php echo esc_url( admin_url( 'options.php' ) ); ?>">
242
- <?php wp_nonce_field( 'email-options' ); ?>
243
-
244
- <table class="form-table">
245
- <tr valign="top">
246
- <th scope="row">
247
- <label for="mail_from"><?php esc_html_e( 'From Email', 'wp-mail-smtp' ); ?></label>
248
- </th>
249
- <td>
250
- <input name="mail_from" type="email" id="mail_from" value="<?php echo esc_attr( get_option( 'mail_from' ) ); ?>" size="40" class="regular-text"/>
251
-
252
- <p class="description">
253
- <?php
254
- esc_html_e( 'You can specify the email address that emails should be sent from. If you leave this blank, the default email will be used.', 'wp-mail-smtp' );
255
- if ( get_option( 'db_version' ) < 6124 ) {
256
- print( '<br /><span style="color: red;">' );
257
- _e( '<strong>Please Note:</strong> You appear to be using a version of WordPress prior to 2.3. Please ignore the From Name field and instead enter Name&lt;email@domain.com&gt; in this field.', 'wp-mail-smtp' );
258
- print( '</span>' );
259
- }
260
- ?>
261
- </p>
262
- </td>
263
- </tr>
264
- <tr valign="top">
265
- <th scope="row">
266
- <label for="mail_from_name"><?php esc_html_e( 'From Name', 'wp-mail-smtp' ); ?></label>
267
- </th>
268
- <td>
269
- <input name="mail_from_name" type="text" id="mail_from_name" value="<?php echo esc_attr( get_option( 'mail_from_name' ) ); ?>" size="40" class="regular-text"/>
270
-
271
- <p class="description">
272
- <?php esc_html_e( 'You can specify the name that emails should be sent from. If you leave this blank, the emails will be sent from WordPress.', 'wp-mail-smtp' ); ?>
273
- </p>
274
- </td>
275
- </tr>
276
- </table>
277
-
278
- <table class="form-table">
279
- <tr valign="top">
280
- <th scope="row">
281
- <?php esc_html_e( 'Mailer', 'wp-mail-smtp' ); ?>
282
- </th>
283
- <td>
284
- <fieldset>
285
- <legend class="screen-reader-text">
286
- <span><?php esc_html_e( 'Mailer', 'wp-mail-smtp' ); ?></span>
287
- </legend>
288
-
289
- <p>
290
- <input id="mailer_smtp" class="wpms_mailer" type="radio" name="mailer" value="smtp" <?php checked( 'smtp', get_option( 'mailer' ) ); ?> />
291
- <label for="mailer_smtp"><?php esc_html_e( 'Send all WordPress emails via SMTP.', 'wp-mail-smtp' ); ?></label>
292
- </p>
293
- <p>
294
- <input id="mailer_mail" class="wpms_mailer" type="radio" name="mailer" value="mail" <?php checked( 'mail', get_option( 'mailer' ) ); ?> />
295
- <label for="mailer_mail"><?php esc_html_e( 'Use the PHP mail() function to send emails.', 'wp-mail-smtp' ); ?></label>
296
- </p>
297
-
298
- <?php if ( wp_mail_smtp_is_pepipost_active() ) : ?>
299
- <p>
300
- <input id="mailer_pepipost" class="wpms_mailer" type="radio" name="mailer" value="pepipost" <?php checked( 'pepipost', get_option( 'mailer' ) ); ?> />
301
- <label for="mailer_pepipost"><?php esc_html_e( 'Use Pepipost SMTP to send emails.', 'wp-mail-smtp' ); ?></label>
302
- </p>
303
- <p class="description">
304
- <?php
305
- printf(
306
- /* translators: %1$s - link start; %2$s - link end. */
307
- esc_html__( 'Looking for high inbox delivery? Try Pepipost with easy setup and free emails. Learn more %1$shere%2$s.', 'wp-mail-smtp' ),
308
- '<a href="https://app1.pepipost.com/index.php/login/wp_mail_smtp?page=signup&utm_source=WordPress&utm_campaign=Plugins&utm_medium=wp_mail_smtp&utm_term=organic&code=WP-MAIL-SMTP" target="_blank">',
309
- '</a>'
310
- );
311
- ?>
312
- </p>
313
- <?php endif; ?>
314
- </fieldset>
315
- </td>
316
- </tr>
317
- </table>
318
-
319
- <table class="form-table">
320
- <tr valign="top">
321
- <th scope="row">
322
- <?php esc_html_e( 'Return Path', 'wp-mail-smtp' ); ?>
323
- </th>
324
- <td>
325
- <fieldset>
326
- <legend class="screen-reader-text">
327
- <span><?php esc_html_e( 'Return Path', 'wp-mail-smtp' ); ?></span>
328
- </legend>
329
-
330
- <label for="mail_set_return_path">
331
- <input name="mail_set_return_path" type="checkbox" id="mail_set_return_path" value="true" <?php checked( 'true', get_option( 'mail_set_return_path' ) ); ?> />
332
- <?php esc_html_e( 'Set the return-path to match the From Email', 'wp-mail-smtp' ); ?>
333
- </label>
334
-
335
- <p class="description">
336
- <?php esc_html_e( 'Return Path indicates where non-delivery receipts - or bounce messages - are to be sent.', 'wp-mail-smtp' ); ?>
337
- </p>
338
- </fieldset>
339
- </td>
340
- </tr>
341
- </table>
342
-
343
- <table class="form-table">
344
- <tr valign="top">
345
- <th scope="row">
346
- <?php _e( 'Hide Announcements', 'wp-mail-smtp' ); ?>
347
- </th>
348
- <td>
349
- <fieldset>
350
- <legend class="screen-reader-text">
351
- <span><?php _e( 'Hide Announcements', 'wp-mail-smtp' ); ?></span>
352
- </legend>
353
-
354
- <label for="wp_mail_smtp_am_notifications_hidden">
355
- <input name="wp_mail_smtp_am_notifications_hidden" type="checkbox" id="wp_mail_smtp_am_notifications_hidden" value="true" <?php checked( 'true', get_option( 'wp_mail_smtp_am_notifications_hidden' ) ); ?> />
356
- <?php _e( 'Check this if you would like to hide plugin announcements and update details.', 'wp-mail-smtp' ); ?>
357
- </label>
358
- </fieldset>
359
- </td>
360
- </tr>
361
- </table>
362
-
363
- <p class="submit">
364
- <input type="submit" name="submit" id="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'wp-mail-smtp' ); ?>"/>
365
- </p>
366
-
367
- <div id="wpms_section_smtp" class="wpms_section">
368
- <h3>
369
- <?php esc_html_e( 'SMTP Options', 'wp-mail-smtp' ); ?>
370
- </h3>
371
- <p><?php esc_html_e( 'These options only apply if you have chosen to send mail by SMTP above.', 'wp-mail-smtp' ); ?></p>
372
-
373
- <table class="form-table">
374
- <tr valign="top">
375
- <th scope="row">
376
- <label for="smtp_host"><?php esc_html_e( 'SMTP Host', 'wp-mail-smtp' ); ?></label>
377
- </th>
378
- <td>
379
- <input name="smtp_host" type="text" id="smtp_host" value="<?php echo intval( get_option( 'smtp_host' ) ); ?>" size="40" class="regular-text"/>
380
- </td>
381
- </tr>
382
- <tr valign="top">
383
- <th scope="row">
384
- <label for="smtp_port"><?php esc_html_e( 'SMTP Port', 'wp-mail-smtp' ); ?></label>
385
- </th>
386
- <td>
387
- <input name="smtp_port" type="text" id="smtp_port" value="<?php echo esc_attr( get_option( 'smtp_port' ) ); ?>" size="6" class="regular-text"/>
388
- </td>
389
- </tr>
390
- <tr valign="top">
391
- <th scope="row"><?php esc_html_e( 'Encryption', 'wp-mail-smtp' ); ?> </th>
392
- <td>
393
- <fieldset>
394
- <legend class="screen-reader-text">
395
- <span><?php esc_html_e( 'Encryption', 'wp-mail-smtp' ); ?></span>
396
- </legend>
397
-
398
- <input id="smtp_ssl_none" type="radio" name="smtp_ssl" value="none" <?php checked( 'none', get_option( 'smtp_ssl' ) ); ?> />
399
- <label for="smtp_ssl_none">
400
- <span><?php esc_html_e( 'No encryption.', 'wp-mail-smtp' ); ?></span>
401
- </label><br/>
402
-
403
- <input id="smtp_ssl_ssl" type="radio" name="smtp_ssl" value="ssl" <?php checked( 'ssl', get_option( 'smtp_ssl' ) ); ?> />
404
- <label for="smtp_ssl_ssl">
405
- <span><?php esc_html_e( 'Use SSL encryption.', 'wp-mail-smtp' ); ?></span>
406
- </label><br/>
407
-
408
- <input id="smtp_ssl_tls" type="radio" name="smtp_ssl" value="tls" <?php checked( 'tls', get_option( 'smtp_ssl' ) ); ?> />
409
- <label for="smtp_ssl_tls">
410
- <span><?php esc_html_e( 'Use TLS encryption.', 'wp-mail-smtp' ); ?></span>
411
- </label>
412
-
413
- <p class="description"><?php esc_html_e( 'TLS is not the same as STARTTLS. For most servers SSL is the recommended option.', 'wp-mail-smtp' ); ?></p>
414
- </fieldset>
415
- </td>
416
- </tr>
417
- <tr valign="top">
418
- <th scope="row"><?php esc_html_e( 'Authentication', 'wp-mail-smtp' ); ?> </th>
419
- <td>
420
- <fieldset>
421
- <legend class="screen-reader-text">
422
- <span><?php esc_html_e( 'Authentication', 'wp-mail-smtp' ); ?></span>
423
- </legend>
424
-
425
- <input id="smtp_auth_false" type="radio" name="smtp_auth" value="false" <?php checked( 'false', get_option( 'smtp_auth' ) ); ?> />
426
- <label for="smtp_auth_false">
427
- <span><?php esc_html_e( 'No: Do not use SMTP authentication.', 'wp-mail-smtp' ); ?></span>
428
- </label><br/>
429
-
430
- <input id="smtp_auth_true" type="radio" name="smtp_auth" value="true" <?php checked( 'true', get_option( 'smtp_auth' ) ); ?> />
431
- <label for="smtp_auth_true">
432
- <span><?php esc_html_e( 'Yes: Use SMTP authentication.', 'wp-mail-smtp' ); ?></span>
433
- </label><br/>
434
-
435
- <p class="description">
436
- <?php esc_html_e( 'If this is set to no, the values below are ignored.', 'wp-mail-smtp' ); ?>
437
- </p>
438
- </fieldset>
439
- </td>
440
- </tr>
441
- <tr valign="top">
442
- <th scope="row">
443
- <label for="smtp_user"><?php esc_html_e( 'Username', 'wp-mail-smtp' ); ?></label>
444
- </th>
445
- <td>
446
- <input name="smtp_user" type="text" id="smtp_user" value="<?php echo esc_attr( get_option( 'smtp_user' ) ); ?>" size="40" class="code" autocomplete="off"/>
447
- </td>
448
- </tr>
449
- <tr valign="top">
450
- <th scope="row">
451
- <label for="smtp_pass"><?php esc_html_e( 'Password', 'wp-mail-smtp' ); ?></label>
452
- </th>
453
- <td>
454
- <input name="smtp_pass" type="password" id="smtp_pass" value="<?php echo esc_attr( get_option( 'smtp_pass' ) ); ?>" size="40" class="code" autocomplete="off"/>
455
-
456
- <p class="description">
457
- <?php esc_html_e( 'This is in plain text because it must not be stored encrypted.', 'wp-mail-smtp' ); ?>
458
- </p>
459
- </td>
460
- </tr>
461
- </table>
462
-
463
- <p class="submit">
464
- <input type="submit" name="submit" id="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'wp-mail-smtp' ); ?>"/>
465
- </p>
466
- </div><!-- #wpms_section_smtp -->
467
-
468
- <?php if ( wp_mail_smtp_is_pepipost_active() ) : ?>
469
- <div id="wpms_section_pepipost" class="wpms_section">
470
- <h3>
471
- <?php esc_html_e( 'Pepipost SMTP Options', 'wp-mail-smtp' ); ?>
472
- </h3>
473
- <p>
474
- <?php
475
- printf(
476
- /* translators: %s - Pepipost registration URL. */
477
- esc_html__( 'You need to signup on %s to get the SMTP username/password.', 'wp-mail-smtp' ),
478
- '<a href="https://app1.pepipost.com/index.php/login/wp_mail_smtp?page=signup&utm_source=WordPress&utm_campaign=Plugins&utm_medium=wp_mail_smtp&utm_term=organic&code=WP-MAIL-SMTP" target="_blank">Pepipost</a>',
479
- ''
480
- );
481
- ?>
482
- </p>
483
- <table class="form-table">
484
- <tr valign="top">
485
- <th scope="row">
486
- <label for="pepipost_user"><?php esc_html_e( 'Username', 'wp-mail-smtp' ); ?></label>
487
- </th>
488
- <td>
489
- <input name="pepipost_user" type="text" id="pepipost_user" value="<?php echo esc_attr( get_option( 'pepipost_user' ) ); ?>" size="40" class="code"/>
490
- </td>
491
- </tr>
492
- <tr valign="top">
493
- <th scope="row">
494
- <label for="pepipost_pass"><?php esc_html_e( 'Password', 'wp-mail-smtp' ); ?></label>
495
- </th>
496
- <td>
497
- <input name="pepipost_pass" type="text" id="pepipost_pass" value="<?php echo esc_attr( get_option( 'pepipost_pass' ) ); ?>" size="40" class="code"/>
498
- </td>
499
- </tr>
500
- <tr valign="top">
501
- <th scope="row">
502
- <label for="pepipost_port"><?php esc_html_e( 'SMTP Port', 'wp-mail-smtp' ); ?></label>
503
- </th>
504
- <td>
505
- <input name="pepipost_port" type="text" id="pepipost_port" value="<?php echo intval( get_option( 'pepipost_port' ) ); ?>" size="6" class="regular-text"/>
506
- </td>
507
- </tr>
508
- <tr valign="top">
509
- <th scope="row">
510
- <?php esc_html_e( 'Encryption', 'wp-mail-smtp' ); ?>
511
- </th>
512
- <td>
513
- <fieldset>
514
- <legend class="screen-reader-text">
515
- <span>
516
- <?php esc_html_e( 'Encryption', 'wp-mail-smtp' ); ?>
517
- </span>
518
- </legend>
519
-
520
- <input id="pepipost_ssl_none" type="radio" name="pepipost_ssl" value="none" <?php checked( 'none', get_option( 'pepipost_ssl' ) ); ?> />
521
- <label for="pepipost_ssl_none">
522
- <span><?php esc_html_e( 'No encryption.', 'wp-mail-smtp' ); ?></span>
523
- </label><br/>
524
-
525
- <input id="pepipost_ssl_ssl" type="radio" name="pepipost_ssl" value="ssl" <?php checked( 'ssl', get_option( 'pepipost_ssl' ) ); ?> />
526
- <label for="pepipost_ssl_ssl">
527
- <span><?php esc_html_e( 'Use SSL encryption.', 'wp-mail-smtp' ); ?></span>
528
- </label><br/>
529
-
530
- <input id="pepipost_ssl_tls" type="radio" name="pepipost_ssl" value="tls" <?php checked( 'tls', get_option( 'pepipost_ssl' ) ); ?> />
531
- <label for="pepipost_ssl_tls">
532
- <span><?php esc_html_e( 'Use TLS encryption.', 'wp-mail-smtp' ); ?></span>
533
- </label>
534
- </fieldset>
535
- </td>
536
- </tr>
537
- </table>
538
-
539
- <p class="submit">
540
- <input type="submit" name="submit" id="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'wp-mail-smtp' ); ?>"/>
541
- </p>
542
- </div><!-- #wpms_section_pepipost -->
543
- <?php endif; ?>
544
-
545
- <input type="hidden" name="action" value="update"/>
546
- <input type="hidden" name="option_page" value="email">
547
- </form>
548
-
549
- <h3><?php esc_html_e( 'Send a Test Email', 'wp-mail-smtp' ); ?></h3>
550
-
551
- <form method="POST" action="">
552
- <?php wp_nonce_field( 'test-email' ); ?>
553
-
554
- <table class="form-table">
555
- <tr valign="top">
556
- <th scope="row">
557
- <label for="to"><?php esc_html_e( 'To', 'wp-mail-smtp' ); ?></label>
558
- </th>
559
- <td>
560
- <input name="to" type="email" id="to" value="" size="40" class="code"/>
561
- <p class="description"><?php esc_html_e( 'Type an email address here and then click Send Test to generate a test email.', 'wp-mail-smtp' ); ?></p>
562
- </td>
563
- </tr>
564
- </table>
565
-
566
- <p class="submit">
567
- <input type="submit" name="wpms_action" id="wpms_action" class="button-primary" value="<?php esc_attr_e( 'Send Test', 'wp-mail-smtp' ); ?>"/>
568
- </p>
569
- </form>
570
-
571
- <script type="text/javascript">
572
- /* globals jQuery */
573
- var wpmsOnMailerChange = function ( mailer ) {
574
- // Hide all the mailer forms.
575
- jQuery( '.wpms_section' ).hide();
576
- // Show the target mailer form.
577
- jQuery( '#wpms_section_' + mailer ).show();
578
- };
579
- jQuery( document ).ready( function () {
580
- // Call wpmsOnMailerChange() on startup with the current mailer.
581
- wpmsOnMailerChange( jQuery( 'input.wpms_mailer:checked' ).val() );
582
-
583
- // Watch the mailer for any changes
584
- jQuery( 'input.wpms_mailer' ).on( 'change', function ( e ) {
585
- // Call the wpmsOnMailerChange() handler, passing the value of the newly selected mailer.
586
- wpmsOnMailerChange( jQuery( e.target ).val() );
587
- } );
588
- } );
589
- </script>
590
-
591
- </div>
592
- <?php
593
- } // End of wp_mail_smtp_options_page() function definition.
594
- endif;
595
-
596
- if ( ! function_exists( 'wp_mail_smtp_menus' ) ) :
597
- /**
598
- * This function adds the required page (only 1 at the moment).
599
- */
600
- function wp_mail_smtp_menus() {
601
-
602
- if ( function_exists( 'add_submenu_page' ) ) {
603
- add_options_page( esc_html__( 'WP Mail SMTP Settings', 'wp-mail-smtp' ), esc_html__( 'WP Mail SMTP', 'wp-mail-smtp' ), 'manage_options', __FILE__, 'wp_mail_smtp_options_page' );
604
- }
605
- } // End of wp_mail_smtp_menus() function definition.
606
- endif;
607
-
608
- if ( ! function_exists( 'wp_mail_smtp_mail_from' ) ) :
609
- /**
610
- * This function sets the from email value.
611
- *
612
- * @param string $orig
613
- *
614
- * @return string
615
- */
616
- function wp_mail_smtp_mail_from( $orig ) {
617
- /*
618
- * This is copied from pluggable.php lines 348-354 as at revision 10150
619
- * http://trac.wordpress.org/browser/branches/2.7/wp-includes/pluggable.php#L348.
620
- */
621
-
622
- // In case of CLI we don't have SERVER_NAME, so use host name instead, may be not a domain name.
623
- $server_name = ! empty( $_SERVER['SERVER_NAME'] ) ? $_SERVER['SERVER_NAME'] : wp_parse_url( get_home_url( get_current_blog_id() ), PHP_URL_HOST );
624
-
625
- // Get the site domain and get rid of www.
626
- $sitename = strtolower( $server_name );
627
- if ( substr( $sitename, 0, 4 ) === 'www.' ) {
628
- $sitename = substr( $sitename, 4 );
629
- }
630
-
631
- $default_from = 'wordpress@' . $sitename;
632
-
633
- /*
634
- * End of copied code.
635
- */
636
-
637
- // If the from email is not the default, return it unchanged.
638
- if ( $orig !== $default_from ) {
639
- return $orig;
640
- }
641
-
642
- if (
643
- defined( 'WPMS_ON' ) && WPMS_ON &&
644
- defined( 'WPMS_MAIL_FROM' )
645
- ) {
646
- $mail_from_email = WPMS_MAIL_FROM;
647
-
648
- if ( ! empty( $mail_from_email ) ) {
649
- return $mail_from_email;
650
- }
651
- }
652
-
653
- if ( is_email( get_option( 'mail_from' ), false ) ) {
654
- return get_option( 'mail_from' );
655
- }
656
-
657
- // If in doubt, return the original value.
658
- return $orig;
659
- } // End of wp_mail_smtp_mail_from() function definition.
660
- endif;
661
-
662
- if ( ! function_exists( 'wp_mail_smtp_mail_from_name' ) ) :
663
- /**
664
- * This function sets the from name value.
665
- *
666
- * @param string $orig
667
- *
668
- * @return string
669
- */
670
- function wp_mail_smtp_mail_from_name( $orig ) {
671
-
672
- // Only filter if the from name is the default.
673
- if ( 'WordPress' === $orig ) {
674
- if (
675
- defined( 'WPMS_ON' ) && WPMS_ON &&
676
- defined( 'WPMS_MAIL_FROM_NAME' )
677
- ) {
678
- $mail_from_name = WPMS_MAIL_FROM_NAME;
679
-
680
- if ( ! empty( $mail_from_name ) ) {
681
- return $mail_from_name;
682
- }
683
- }
684
-
685
- $from_name = get_option( 'mail_from_name' );
686
- if ( ! empty( $from_name ) && is_string( $from_name ) ) {
687
- return $from_name;
688
- }
689
- }
690
-
691
- return $orig;
692
- }
693
- endif;
694
-
695
- /**
696
- * Add a link to Settings page of a plugin on Plugins page.
697
- *
698
- * @param array $links
699
- * @param string $file
700
- *
701
- * @return mixed
702
- */
703
- function wp_mail_plugin_action_links( $links, $file ) {
704
-
705
- if ( plugin_basename( __FILE__ ) !== $file ) {
706
- return $links;
707
- }
708
-
709
- $settings_link = '<a href="options-general.php?page=' . plugin_basename( __FILE__ ) . '">' . esc_html__( 'Settings', 'wp-mail-smtp' ) . '</a>';
710
-
711
- array_unshift( $links, $settings_link );
712
-
713
- return $links;
714
- }
715
-
716
- /**
717
- * Awesome Motive Notifications.
718
- *
719
- * @since 0.11
720
- */
721
- function wp_mail_smtp_am_notifications() {
722
-
723
- $is_hidden = get_option( 'wp_mail_smtp_am_notifications_hidden', '' );
724
-
725
- if ( 'true' === $is_hidden ) {
726
- return;
727
- }
728
-
729
- if ( ! class_exists( 'WPMS_AM_Notification' ) ) {
730
- require_once dirname( __FILE__ ) . '/class-wpms-am-notification.php';
731
- }
732
-
733
- new WPMS_AM_Notification( 'smtp', WPMS_PLUGIN_VER );
734
- }
735
-
736
- add_action( 'plugins_loaded', 'wp_mail_smtp_am_notifications' );
737
-
738
- /**
739
- * Check whether the site is using Pepipost or not.
740
- *
741
- * @since 0.11
742
- *
743
- * @return bool
744
- */
745
- function wp_mail_smtp_is_pepipost_active() {
746
- return apply_filters( 'wp_mail_smtp_options_is_pepipost_active', 'pepipost' === get_option( 'mailer' ) );
747
- }
748
-
749
- /**
750
- * Check the current PHP version and display a notice if on unsupported PHP.
751
- *
752
- * @since 0.11
753
- */
754
- function wp_mail_smtp_check_php_version() {
755
-
756
- // Display for admins only.
757
- if ( ! is_super_admin() ) {
758
- return;
759
- }
760
-
761
- // Display on Dashboard page only.
762
- if ( isset( $GLOBALS['pagenow'] ) && 'index.php' !== $GLOBALS['pagenow'] ) {
763
- return;
764
- }
765
-
766
- echo '<div class="notice notice-error">' .
767
- '<p>' .
768
- sprintf(
769
- /* translators: %1$s - WP Mail SMTP plugin name; %2$s - opening a link tag; %3$s - closing a link tag. */
770
- esc_html__(
771
- 'Your site is running an outdated version of PHP that is no longer supported and may cause issues with %1$s. %2$sRead more%3$s for additional information.',
772
- 'wp-mail-smtp'
773
- ),
774
- '<strong>WP Mail SMTP</strong>',
775
- '<a href="https://wpforms.com/docs/supported-php-version/" target="_blank">',
776
- '</a>'
777
- ) .
778
- '</p>' .
779
- '</div>';
780
- }
781
-
782
- add_action( 'admin_notices', 'wp_mail_smtp_check_php_version' );
783
-
784
- // Add an action on phpmailer_init.
785
- add_action( 'phpmailer_init', 'phpmailer_init_smtp' );
786
-
787
- if ( ! defined( 'WPMS_ON' ) || ! WPMS_ON ) {
788
- // Whitelist our options.
789
- add_filter( 'whitelist_options', 'wp_mail_smtp_whitelist_options' );
790
- // Add the create pages options.
791
- add_action( 'admin_menu', 'wp_mail_smtp_menus' );
792
- // Add an activation hook for this plugin.
793
- register_activation_hook( __FILE__, 'wp_mail_smtp_activate' );
794
- // Adds "Settings" link to the Plugins page.
795
- add_filter( 'plugin_action_links', 'wp_mail_plugin_action_links', 10, 2 );
796
- }
797
-
798
- // Add filters to replace the mail from name and email address.
799
- add_filter( 'wp_mail_from', 'wp_mail_smtp_mail_from' );
800
- add_filter( 'wp_mail_from_name', 'wp_mail_smtp_mail_from_name' );
801
-
802
- load_plugin_textdomain( 'wp-mail-smtp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
1
+ <?php
2
+ /**
3
+ * This is an obsolete version of the plugin, as of 0.11.2 released on 2017-11-28.
4
+ * This code is loaded only when the site runs on PHP 5.2.
5
+ */
6
+
7
+ /**
8
+ * Array of options and their default values.
9
+ * This is horrible, should be cleaned up at some point.
10
+ */
11
+ global $wpms_options;
12
+ $wpms_options = array(
13
+ 'mail_from' => '',
14
+ 'mail_from_name' => '',
15
+ 'mailer' => 'smtp',
16
+ 'mail_set_return_path' => 'false',
17
+ 'smtp_host' => 'localhost',
18
+ 'smtp_port' => '25',
19
+ 'smtp_ssl' => 'none',
20
+ 'smtp_auth' => false,
21
+ 'smtp_user' => '',
22
+ 'smtp_pass' => '',
23
+ 'pepipost_user' => '',
24
+ 'pepipost_pass' => '',
25
+ 'pepipost_port' => '2525',
26
+ 'pepipost_ssl' => 'none',
27
+ 'wp_mail_smtp_am_notifications_hidden' => '',
28
+ );
29
+
30
+ /**
31
+ * Activation function. This function creates the required options and defaults.
32
+ */
33
+ if ( ! function_exists( 'wp_mail_smtp_activate' ) ) :
34
+ /**
35
+ * What to do on plugin activation.
36
+ */
37
+ function wp_mail_smtp_activate() {
38
+
39
+ global $wpms_options;
40
+
41
+ // Create the required options...
42
+ foreach ( $wpms_options as $name => $val ) {
43
+ add_option( $name, $val );
44
+ }
45
+ }
46
+ endif;
47
+
48
+ if ( ! function_exists( 'wp_mail_smtp_whitelist_options' ) ) :
49
+ /**
50
+ * Whitelist plugin options.
51
+ *
52
+ * @param array $whitelist_options
53
+ *
54
+ * @return mixed
55
+ */
56
+ function wp_mail_smtp_whitelist_options( $whitelist_options ) {
57
+
58
+ global $wpms_options;
59
+
60
+ // Add our options to the array.
61
+ $whitelist_options['email'] = array_keys( $wpms_options );
62
+
63
+ return $whitelist_options;
64
+ }
65
+ endif;
66
+
67
+ /**
68
+ * To avoid any (very unlikely) clashes, check if the function already exists.
69
+ */
70
+ if ( ! function_exists( 'phpmailer_init_smtp' ) ) :
71
+ /**
72
+ * This code is copied, from wp-includes/pluggable.php as at version 2.2.2.
73
+ *
74
+ * @param PHPMailer $phpmailer It's passed by reference, so no need to return anything.
75
+ */
76
+ function phpmailer_init_smtp( $phpmailer ) {
77
+ /*
78
+ * If constants are defined, apply them.
79
+ * We should have defined all required constants before using them.
80
+ */
81
+ if (
82
+ defined( 'WPMS_ON' ) && WPMS_ON &&
83
+ defined( 'WPMS_MAILER' )
84
+ ) {
85
+ $phpmailer->Mailer = WPMS_MAILER;
86
+
87
+ if ( defined( 'WPMS_SET_RETURN_PATH' ) && WPMS_SET_RETURN_PATH ) {
88
+ $phpmailer->Sender = $phpmailer->From;
89
+ }
90
+
91
+ if (
92
+ WPMS_MAILER === 'smtp' &&
93
+ defined( 'WPMS_SSL' ) &&
94
+ defined( 'WPMS_SMTP_HOST' ) &&
95
+ defined( 'WPMS_SMTP_PORT' )
96
+ ) {
97
+ $phpmailer->SMTPSecure = WPMS_SSL;
98
+ $phpmailer->Host = WPMS_SMTP_HOST;
99
+ $phpmailer->Port = WPMS_SMTP_PORT;
100
+
101
+ if (
102
+ defined( 'WPMS_SMTP_AUTH' ) && WPMS_SMTP_AUTH &&
103
+ defined( 'WPMS_SMTP_USER' ) &&
104
+ defined( 'WPMS_SMTP_PASS' )
105
+ ) {
106
+ $phpmailer->SMTPAuth = true;
107
+ $phpmailer->Username = WPMS_SMTP_USER;
108
+ $phpmailer->Password = WPMS_SMTP_PASS;
109
+ }
110
+ }
111
+ } else {
112
+ $option_mailer = get_option( 'mailer' );
113
+ $option_smtp_host = get_option( 'smtp_host' );
114
+ $option_smtp_ssl = get_option( 'smtp_ssl' );
115
+
116
+ // Check that mailer is not blank, and if mailer=smtp, host is not blank.
117
+ if (
118
+ ! $option_mailer ||
119
+ ( 'smtp' === $option_mailer && ! $option_smtp_host )
120
+ ) {
121
+ return;
122
+ }
123
+
124
+ // If the mailer is pepipost, make sure we have a username and password.
125
+ if ( 'pepipost' === $option_mailer && ( ! get_option( 'pepipost_user' ) && ! get_option( 'pepipost_pass' ) ) ) {
126
+ return;
127
+ }
128
+
129
+ // Set the mailer type as per config above, this overrides the already called isMail method.
130
+ $phpmailer->Mailer = $option_mailer;
131
+
132
+ // Set the Sender (return-path) if required.
133
+ if ( get_option( 'mail_set_return_path' ) ) {
134
+ $phpmailer->Sender = $phpmailer->From;
135
+ }
136
+
137
+ // Set the SMTPSecure value, if set to none, leave this blank.
138
+ $phpmailer->SMTPSecure = $option_smtp_ssl;
139
+ if ( 'none' === $option_smtp_ssl ) {
140
+ $phpmailer->SMTPSecure = '';
141
+ $phpmailer->SMTPAutoTLS = false;
142
+ }
143
+
144
+ // If we're sending via SMTP, set the host.
145
+ if ( 'smtp' === $option_mailer ) {
146
+ // Set the other options.
147
+ $phpmailer->Host = $option_smtp_host;
148
+ $phpmailer->Port = get_option( 'smtp_port' );
149
+
150
+ // If we're using smtp auth, set the username & password.
151
+ if ( get_option( 'smtp_auth' ) === 'true' ) {
152
+ $phpmailer->SMTPAuth = true;
153
+ $phpmailer->Username = get_option( 'smtp_user' );
154
+ $phpmailer->Password = get_option( 'smtp_pass' );
155
+ }
156
+ } elseif ( 'pepipost' === $option_mailer ) {
157
+ // Set the Pepipost settings.
158
+ $phpmailer->Mailer = 'smtp';
159
+ $phpmailer->Host = 'smtp.pepipost.com';
160
+ $phpmailer->Port = get_option( 'pepipost_port' );
161
+ $phpmailer->SMTPSecure = get_option( 'pepipost_ssl' ) === 'none' ? '' : get_option( 'pepipost_ssl' );
162
+ $phpmailer->SMTPAuth = true;
163
+ $phpmailer->Username = get_option( 'pepipost_user' );
164
+ $phpmailer->Password = get_option( 'pepipost_pass' );
165
+ }
166
+ }
167
+
168
+ // You can add your own options here, see the phpmailer documentation for more info: http://phpmailer.sourceforge.net/docs/.
169
+ /** @noinspection PhpUnusedLocalVariableInspection It's passed by reference. */
170
+ $phpmailer = apply_filters( 'wp_mail_smtp_custom_options', $phpmailer );
171
+ }
172
+ endif;
173
+
174
+ if ( ! function_exists( 'wp_mail_smtp_options_page' ) ) :
175
+ /**
176
+ * This function outputs the plugin options page.
177
+ */
178
+ function wp_mail_smtp_options_page() {
179
+
180
+ global $phpmailer;
181
+
182
+ // Make sure the PHPMailer class has been instantiated
183
+ // (copied verbatim from wp-includes/pluggable.php)
184
+ // (Re)create it, if it's gone missing.
185
+ if ( ! is_object( $phpmailer ) || ! is_a( $phpmailer, 'PHPMailer' ) ) {
186
+ require_once ABSPATH . WPINC . '/class-phpmailer.php';
187
+ $phpmailer = new PHPMailer( true );
188
+ }
189
+
190
+ // Send a test mail if necessary.
191
+ if (
192
+ isset( $_POST['wpms_action'] ) &&
193
+ esc_html__( 'Send Test', 'wp-mail-smtp' ) === sanitize_text_field( $_POST['wpms_action'] ) &&
194
+ is_email( $_POST['to'] )
195
+ ) {
196
+
197
+ check_admin_referer( 'test-email' );
198
+
199
+ // Set up the mail variables.
200
+ $to = sanitize_text_field( $_POST['to'] );
201
+ /* translators: %s - email address where test mail will be sent to. */
202
+ $subject = 'WP Mail SMTP: ' . sprintf( esc_html__( 'Test mail to %s', 'wp-mail-smtp' ), $to );
203
+ $message = esc_html__( 'This is a test email generated by the WP Mail SMTP WordPress plugin.', 'wp-mail-smtp' );
204
+
205
+ // Set SMTPDebug level, default is 2 (commands + data + connection status).
206
+ $phpmailer->SMTPDebug = apply_filters( 'wp_mail_smtp_admin_test_email_smtp_debug', 2 );
207
+
208
+ // Start output buffering to grab smtp debugging output.
209
+ ob_start();
210
+
211
+ // Send the test mail.
212
+ $result = wp_mail( $to, $subject, $message );
213
+
214
+ // Grab the smtp debugging output.
215
+ $smtp_debug = ob_get_clean();
216
+
217
+ // Output the response.
218
+ ?>
219
+ <div id="message" class="updated notice is-dismissible"><p><strong><?php esc_html_e( 'Test Message Sent', 'wp-mail-smtp' ); ?></strong></p>
220
+ <p><?php esc_html_e( 'The result was:', 'wp-mail-smtp' ); ?></p>
221
+ <pre><?php var_dump( $result ); ?></pre>
222
+
223
+ <p><?php esc_html_e( 'The full debugging output is shown below:', 'wp-mail-smtp' ); ?></p>
224
+ <pre><?php print_r( $phpmailer ); ?></pre>
225
+
226
+ <p><?php esc_html_e( 'The SMTP debugging output is shown below:', 'wp-mail-smtp' ); ?></p>
227
+ <pre><?php echo $smtp_debug; ?></pre>
228
+ </div>
229
+ <?php
230
+
231
+ // Destroy $phpmailer so it doesn't cause issues later.
232
+ unset( $phpmailer );
233
+ }
234
+
235
+ ?>
236
+ <div class="wrap">
237
+ <h2>
238
+ <?php esc_html_e( 'WP Mail SMTP Settings', 'wp-mail-smtp' ); ?>
239
+ </h2>
240
+
241
+ <form method="post" action="<?php echo esc_url( admin_url( 'options.php' ) ); ?>">
242
+ <?php wp_nonce_field( 'email-options' ); ?>
243
+
244
+ <table class="form-table">
245
+ <tr valign="top">
246
+ <th scope="row">
247
+ <label for="mail_from"><?php esc_html_e( 'From Email', 'wp-mail-smtp' ); ?></label>
248
+ </th>
249
+ <td>
250
+ <input name="mail_from" type="email" id="mail_from" value="<?php echo esc_attr( get_option( 'mail_from' ) ); ?>" size="40" class="regular-text"/>
251
+
252
+ <p class="description">
253
+ <?php
254
+ esc_html_e( 'You can specify the email address that emails should be sent from. If you leave this blank, the default email will be used.', 'wp-mail-smtp' );
255
+ if ( get_option( 'db_version' ) < 6124 ) {
256
+ print( '<br /><span style="color: red;">' );
257
+ _e( '<strong>Please Note:</strong> You appear to be using a version of WordPress prior to 2.3. Please ignore the From Name field and instead enter Name&lt;email@domain.com&gt; in this field.', 'wp-mail-smtp' );
258
+ print( '</span>' );
259
+ }
260
+ ?>
261
+ </p>
262
+ </td>
263
+ </tr>
264
+ <tr valign="top">
265
+ <th scope="row">
266
+ <label for="mail_from_name"><?php esc_html_e( 'From Name', 'wp-mail-smtp' ); ?></label>
267
+ </th>
268
+ <td>
269
+ <input name="mail_from_name" type="text" id="mail_from_name" value="<?php echo esc_attr( get_option( 'mail_from_name' ) ); ?>" size="40" class="regular-text"/>
270
+
271
+ <p class="description">
272
+ <?php esc_html_e( 'You can specify the name that emails should be sent from. If you leave this blank, the emails will be sent from WordPress.', 'wp-mail-smtp' ); ?>
273
+ </p>
274
+ </td>
275
+ </tr>
276
+ </table>
277
+
278
+ <table class="form-table">
279
+ <tr valign="top">
280
+ <th scope="row">
281
+ <?php esc_html_e( 'Mailer', 'wp-mail-smtp' ); ?>
282
+ </th>
283
+ <td>
284
+ <fieldset>
285
+ <legend class="screen-reader-text">
286
+ <span><?php esc_html_e( 'Mailer', 'wp-mail-smtp' ); ?></span>
287
+ </legend>
288
+
289
+ <p>
290
+ <input id="mailer_smtp" class="wpms_mailer" type="radio" name="mailer" value="smtp" <?php checked( 'smtp', get_option( 'mailer' ) ); ?> />
291
+ <label for="mailer_smtp"><?php esc_html_e( 'Send all WordPress emails via SMTP.', 'wp-mail-smtp' ); ?></label>
292
+ </p>
293
+ <p>
294
+ <input id="mailer_mail" class="wpms_mailer" type="radio" name="mailer" value="mail" <?php checked( 'mail', get_option( 'mailer' ) ); ?> />
295
+ <label for="mailer_mail"><?php esc_html_e( 'Use the PHP mail() function to send emails.', 'wp-mail-smtp' ); ?></label>
296
+ </p>
297
+
298
+ <?php if ( wp_mail_smtp_is_pepipost_active() ) : ?>
299
+ <p>
300
+ <input id="mailer_pepipost" class="wpms_mailer" type="radio" name="mailer" value="pepipost" <?php checked( 'pepipost', get_option( 'mailer' ) ); ?> />
301
+ <label for="mailer_pepipost"><?php esc_html_e( 'Use Pepipost SMTP to send emails.', 'wp-mail-smtp' ); ?></label>
302
+ </p>
303
+ <p class="description">
304
+ <?php
305
+ printf(
306
+ /* translators: %1$s - link start; %2$s - link end. */
307
+ esc_html__( 'Looking for high inbox delivery? Try Pepipost with easy setup and free emails. Learn more %1$shere%2$s.', 'wp-mail-smtp' ),
308
+ '<a href="https://app1.pepipost.com/index.php/login/wp_mail_smtp?page=signup&utm_source=WordPress&utm_campaign=Plugins&utm_medium=wp_mail_smtp&utm_term=organic&code=WP-MAIL-SMTP" target="_blank">',
309
+ '</a>'
310
+ );
311
+ ?>
312
+ </p>
313
+ <?php endif; ?>
314
+ </fieldset>
315
+ </td>
316
+ </tr>
317
+ </table>
318
+
319
+ <table class="form-table">
320
+ <tr valign="top">
321
+ <th scope="row">
322
+ <?php esc_html_e( 'Return Path', 'wp-mail-smtp' ); ?>
323
+ </th>
324
+ <td>
325
+ <fieldset>
326
+ <legend class="screen-reader-text">
327
+ <span><?php esc_html_e( 'Return Path', 'wp-mail-smtp' ); ?></span>
328
+ </legend>
329
+
330
+ <label for="mail_set_return_path">
331
+ <input name="mail_set_return_path" type="checkbox" id="mail_set_return_path" value="true" <?php checked( 'true', get_option( 'mail_set_return_path' ) ); ?> />
332
+ <?php esc_html_e( 'Set the return-path to match the From Email', 'wp-mail-smtp' ); ?>
333
+ </label>
334
+
335
+ <p class="description">
336
+ <?php esc_html_e( 'Return Path indicates where non-delivery receipts - or bounce messages - are to be sent.', 'wp-mail-smtp' ); ?>
337
+ </p>
338
+ </fieldset>
339
+ </td>
340
+ </tr>
341
+ </table>
342
+
343
+ <table class="form-table">
344
+ <tr valign="top">
345
+ <th scope="row">
346
+ <?php _e( 'Hide Announcements', 'wp-mail-smtp' ); ?>
347
+ </th>
348
+ <td>
349
+ <fieldset>
350
+ <legend class="screen-reader-text">
351
+ <span><?php _e( 'Hide Announcements', 'wp-mail-smtp' ); ?></span>
352
+ </legend>
353
+
354
+ <label for="wp_mail_smtp_am_notifications_hidden">
355
+ <input name="wp_mail_smtp_am_notifications_hidden" type="checkbox" id="wp_mail_smtp_am_notifications_hidden" value="true" <?php checked( 'true', get_option( 'wp_mail_smtp_am_notifications_hidden' ) ); ?> />
356
+ <?php _e( 'Check this if you would like to hide plugin announcements and update details.', 'wp-mail-smtp' ); ?>
357
+ </label>
358
+ </fieldset>
359
+ </td>
360
+ </tr>
361
+ </table>
362
+
363
+ <p class="submit">
364
+ <input type="submit" name="submit" id="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'wp-mail-smtp' ); ?>"/>
365
+ </p>
366
+
367
+ <div id="wpms_section_smtp" class="wpms_section">
368
+ <h3>
369
+ <?php esc_html_e( 'SMTP Options', 'wp-mail-smtp' ); ?>
370
+ </h3>
371
+ <p><?php esc_html_e( 'These options only apply if you have chosen to send mail by SMTP above.', 'wp-mail-smtp' ); ?></p>
372
+
373
+ <table class="form-table">
374
+ <tr valign="top">
375
+ <th scope="row">
376
+ <label for="smtp_host"><?php esc_html_e( 'SMTP Host', 'wp-mail-smtp' ); ?></label>
377
+ </th>
378
+ <td>
379
+ <input name="smtp_host" type="text" id="smtp_host" value="<?php echo intval( get_option( 'smtp_host' ) ); ?>" size="40" class="regular-text"/>
380
+ </td>
381
+ </tr>
382
+ <tr valign="top">
383
+ <th scope="row">
384
+ <label for="smtp_port"><?php esc_html_e( 'SMTP Port', 'wp-mail-smtp' ); ?></label>
385
+ </th>
386
+ <td>
387
+ <input name="smtp_port" type="text" id="smtp_port" value="<?php echo esc_attr( get_option( 'smtp_port' ) ); ?>" size="6" class="regular-text"/>
388
+ </td>
389
+ </tr>
390
+ <tr valign="top">
391
+ <th scope="row"><?php esc_html_e( 'Encryption', 'wp-mail-smtp' ); ?> </th>
392
+ <td>
393
+ <fieldset>
394
+ <legend class="screen-reader-text">
395
+ <span><?php esc_html_e( 'Encryption', 'wp-mail-smtp' ); ?></span>
396
+ </legend>
397
+
398
+ <input id="smtp_ssl_none" type="radio" name="smtp_ssl" value="none" <?php checked( 'none', get_option( 'smtp_ssl' ) ); ?> />
399
+ <label for="smtp_ssl_none">
400
+ <span><?php esc_html_e( 'No encryption.', 'wp-mail-smtp' ); ?></span>
401
+ </label><br/>
402
+
403
+ <input id="smtp_ssl_ssl" type="radio" name="smtp_ssl" value="ssl" <?php checked( 'ssl', get_option( 'smtp_ssl' ) ); ?> />
404
+ <label for="smtp_ssl_ssl">
405
+ <span><?php esc_html_e( 'Use SSL encryption.', 'wp-mail-smtp' ); ?></span>
406
+ </label><br/>
407
+
408
+ <input id="smtp_ssl_tls" type="radio" name="smtp_ssl" value="tls" <?php checked( 'tls', get_option( 'smtp_ssl' ) ); ?> />
409
+ <label for="smtp_ssl_tls">
410
+ <span><?php esc_html_e( 'Use TLS encryption.', 'wp-mail-smtp' ); ?></span>
411
+ </label>
412
+
413
+ <p class="description"><?php esc_html_e( 'TLS is not the same as STARTTLS. For most servers SSL is the recommended option.', 'wp-mail-smtp' ); ?></p>
414
+ </fieldset>
415
+ </td>
416
+ </tr>
417
+ <tr valign="top">
418
+ <th scope="row"><?php esc_html_e( 'Authentication', 'wp-mail-smtp' ); ?> </th>
419
+ <td>
420
+ <fieldset>
421
+ <legend class="screen-reader-text">
422
+ <span><?php esc_html_e( 'Authentication', 'wp-mail-smtp' ); ?></span>
423
+ </legend>
424
+
425
+ <input id="smtp_auth_false" type="radio" name="smtp_auth" value="false" <?php checked( 'false', get_option( 'smtp_auth' ) ); ?> />
426
+ <label for="smtp_auth_false">
427
+ <span><?php esc_html_e( 'No: Do not use SMTP authentication.', 'wp-mail-smtp' ); ?></span>
428
+ </label><br/>
429
+
430
+ <input id="smtp_auth_true" type="radio" name="smtp_auth" value="true" <?php checked( 'true', get_option( 'smtp_auth' ) ); ?> />
431
+ <label for="smtp_auth_true">
432
+ <span><?php esc_html_e( 'Yes: Use SMTP authentication.', 'wp-mail-smtp' ); ?></span>
433
+ </label><br/>
434
+
435
+ <p class="description">
436
+ <?php esc_html_e( 'If this is set to no, the values below are ignored.', 'wp-mail-smtp' ); ?>
437
+ </p>
438
+ </fieldset>
439
+ </td>
440
+ </tr>
441
+ <tr valign="top">
442
+ <th scope="row">
443
+ <label for="smtp_user"><?php esc_html_e( 'Username', 'wp-mail-smtp' ); ?></label>
444
+ </th>
445
+ <td>
446
+ <input name="smtp_user" type="text" id="smtp_user" value="<?php echo esc_attr( get_option( 'smtp_user' ) ); ?>" size="40" class="code" autocomplete="off"/>
447
+ </td>
448
+ </tr>
449
+ <tr valign="top">
450
+ <th scope="row">
451
+ <label for="smtp_pass"><?php esc_html_e( 'Password', 'wp-mail-smtp' ); ?></label>
452
+ </th>
453
+ <td>
454
+ <input name="smtp_pass" type="password" id="smtp_pass" value="<?php echo esc_attr( get_option( 'smtp_pass' ) ); ?>" size="40" class="code" autocomplete="off"/>
455
+
456
+ <p class="description">
457
+ <?php esc_html_e( 'This is in plain text because it must not be stored encrypted.', 'wp-mail-smtp' ); ?>
458
+ </p>
459
+ </td>
460
+ </tr>
461
+ </table>
462
+
463
+ <p class="submit">
464
+ <input type="submit" name="submit" id="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'wp-mail-smtp' ); ?>"/>
465
+ </p>
466
+ </div><!-- #wpms_section_smtp -->
467
+
468
+ <?php if ( wp_mail_smtp_is_pepipost_active() ) : ?>
469
+ <div id="wpms_section_pepipost" class="wpms_section">
470
+ <h3>
471
+ <?php esc_html_e( 'Pepipost SMTP Options', 'wp-mail-smtp' ); ?>
472
+ </h3>
473
+ <p>
474
+ <?php
475
+ printf(
476
+ /* translators: %s - Pepipost registration URL. */
477
+ esc_html__( 'You need to signup on %s to get the SMTP username/password.', 'wp-mail-smtp' ),
478
+ '<a href="https://app1.pepipost.com/index.php/login/wp_mail_smtp?page=signup&utm_source=WordPress&utm_campaign=Plugins&utm_medium=wp_mail_smtp&utm_term=organic&code=WP-MAIL-SMTP" target="_blank">Pepipost</a>',
479
+ ''
480
+ );
481
+ ?>
482
+ </p>
483
+ <table class="form-table">
484
+ <tr valign="top">
485
+ <th scope="row">
486
+ <label for="pepipost_user"><?php esc_html_e( 'Username', 'wp-mail-smtp' ); ?></label>
487
+ </th>
488
+ <td>
489
+ <input name="pepipost_user" type="text" id="pepipost_user" value="<?php echo esc_attr( get_option( 'pepipost_user' ) ); ?>" size="40" class="code"/>
490
+ </td>
491
+ </tr>
492
+ <tr valign="top">
493
+ <th scope="row">
494
+ <label for="pepipost_pass"><?php esc_html_e( 'Password', 'wp-mail-smtp' ); ?></label>
495
+ </th>
496
+ <td>
497
+ <input name="pepipost_pass" type="text" id="pepipost_pass" value="<?php echo esc_attr( get_option( 'pepipost_pass' ) ); ?>" size="40" class="code"/>
498
+ </td>
499
+ </tr>
500
+ <tr valign="top">
501
+ <th scope="row">
502
+ <label for="pepipost_port"><?php esc_html_e( 'SMTP Port', 'wp-mail-smtp' ); ?></label>
503
+ </th>
504
+ <td>
505
+ <input name="pepipost_port" type="text" id="pepipost_port" value="<?php echo intval( get_option( 'pepipost_port' ) ); ?>" size="6" class="regular-text"/>
506
+ </td>
507
+ </tr>
508
+ <tr valign="top">
509
+ <th scope="row">
510
+ <?php esc_html_e( 'Encryption', 'wp-mail-smtp' ); ?>
511
+ </th>
512
+ <td>
513
+ <fieldset>
514
+ <legend class="screen-reader-text">
515
+ <span>
516
+ <?php esc_html_e( 'Encryption', 'wp-mail-smtp' ); ?>
517
+ </span>
518
+ </legend>
519
+
520
+ <input id="pepipost_ssl_none" type="radio" name="pepipost_ssl" value="none" <?php checked( 'none', get_option( 'pepipost_ssl' ) ); ?> />
521
+ <label for="pepipost_ssl_none">
522
+ <span><?php esc_html_e( 'No encryption.', 'wp-mail-smtp' ); ?></span>
523
+ </label><br/>
524
+
525
+ <input id="pepipost_ssl_ssl" type="radio" name="pepipost_ssl" value="ssl" <?php checked( 'ssl', get_option( 'pepipost_ssl' ) ); ?> />
526
+ <label for="pepipost_ssl_ssl">
527
+ <span><?php esc_html_e( 'Use SSL encryption.', 'wp-mail-smtp' ); ?></span>
528
+ </label><br/>
529
+
530
+ <input id="pepipost_ssl_tls" type="radio" name="pepipost_ssl" value="tls" <?php checked( 'tls', get_option( 'pepipost_ssl' ) ); ?> />
531
+ <label for="pepipost_ssl_tls">
532
+ <span><?php esc_html_e( 'Use TLS encryption.', 'wp-mail-smtp' ); ?></span>
533
+ </label>
534
+ </fieldset>
535
+ </td>
536
+ </tr>
537
+ </table>
538
+
539
+ <p class="submit">
540
+ <input type="submit" name="submit" id="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'wp-mail-smtp' ); ?>"/>
541
+ </p>
542
+ </div><!-- #wpms_section_pepipost -->
543
+ <?php endif; ?>
544
+
545
+ <input type="hidden" name="action" value="update"/>
546
+ <input type="hidden" name="option_page" value="email">
547
+ </form>
548
+
549
+ <h3><?php esc_html_e( 'Send a Test Email', 'wp-mail-smtp' ); ?></h3>
550
+
551
+ <form method="POST" action="">
552
+ <?php wp_nonce_field( 'test-email' ); ?>
553
+
554
+ <table class="form-table">
555
+ <tr valign="top">
556
+ <th scope="row">
557
+ <label for="to"><?php esc_html_e( 'To', 'wp-mail-smtp' ); ?></label>
558
+ </th>
559
+ <td>
560
+ <input name="to" type="email" id="to" value="" size="40" class="code"/>
561
+ <p class="description"><?php esc_html_e( 'Type an email address here and then click Send Test to generate a test email.', 'wp-mail-smtp' ); ?></p>
562
+ </td>
563
+ </tr>
564
+ </table>
565
+
566
+ <p class="submit">
567
+ <input type="submit" name="wpms_action" id="wpms_action" class="button-primary" value="<?php esc_attr_e( 'Send Test', 'wp-mail-smtp' ); ?>"/>
568
+ </p>
569
+ </form>
570
+
571
+ <script type="text/javascript">
572
+ /* globals jQuery */
573
+ var wpmsOnMailerChange = function ( mailer ) {
574
+ // Hide all the mailer forms.
575
+ jQuery( '.wpms_section' ).hide();
576
+ // Show the target mailer form.
577
+ jQuery( '#wpms_section_' + mailer ).show();
578
+ };
579
+ jQuery( document ).ready( function () {
580
+ // Call wpmsOnMailerChange() on startup with the current mailer.
581
+ wpmsOnMailerChange( jQuery( 'input.wpms_mailer:checked' ).val() );
582
+
583
+ // Watch the mailer for any changes
584
+ jQuery( 'input.wpms_mailer' ).on( 'change', function ( e ) {
585
+ // Call the wpmsOnMailerChange() handler, passing the value of the newly selected mailer.
586
+ wpmsOnMailerChange( jQuery( e.target ).val() );
587
+ } );
588
+ } );
589
+ </script>
590
+
591
+ </div>
592
+ <?php
593
+ } // End of wp_mail_smtp_options_page() function definition.
594
+ endif;
595
+
596
+ if ( ! function_exists( 'wp_mail_smtp_menus' ) ) :
597
+ /**
598
+ * This function adds the required page (only 1 at the moment).
599
+ */
600
+ function wp_mail_smtp_menus() {
601
+
602
+ if ( function_exists( 'add_submenu_page' ) ) {
603
+ add_options_page( esc_html__( 'WP Mail SMTP Settings', 'wp-mail-smtp' ), esc_html__( 'WP Mail SMTP', 'wp-mail-smtp' ), 'manage_options', __FILE__, 'wp_mail_smtp_options_page' );
604
+ }
605
+ } // End of wp_mail_smtp_menus() function definition.
606
+ endif;
607
+
608
+ if ( ! function_exists( 'wp_mail_smtp_mail_from' ) ) :
609
+ /**
610
+ * This function sets the from email value.
611
+ *
612
+ * @param string $orig
613
+ *
614
+ * @return string
615
+ */
616
+ function wp_mail_smtp_mail_from( $orig ) {
617
+ /*
618
+ * This is copied from pluggable.php lines 348-354 as at revision 10150
619
+ * http://trac.wordpress.org/browser/branches/2.7/wp-includes/pluggable.php#L348.
620
+ */
621
+
622
+ // In case of CLI we don't have SERVER_NAME, so use host name instead, may be not a domain name.
623
+ $server_name = ! empty( $_SERVER['SERVER_NAME'] ) ? $_SERVER['SERVER_NAME'] : wp_parse_url( get_home_url( get_current_blog_id() ), PHP_URL_HOST );
624
+
625
+ // Get the site domain and get rid of www.
626
+ $sitename = strtolower( $server_name );
627
+ if ( substr( $sitename, 0, 4 ) === 'www.' ) {
628
+ $sitename = substr( $sitename, 4 );
629
+ }
630
+
631
+ $default_from = 'wordpress@' . $sitename;
632
+
633
+ /*
634
+ * End of copied code.
635
+ */
636
+
637
+ // If the from email is not the default, return it unchanged.
638
+ if ( $orig !== $default_from ) {
639
+ return $orig;
640
+ }
641
+
642
+ if (
643
+ defined( 'WPMS_ON' ) && WPMS_ON &&
644
+ defined( 'WPMS_MAIL_FROM' )
645
+ ) {
646
+ $mail_from_email = WPMS_MAIL_FROM;
647
+
648
+ if ( ! empty( $mail_from_email ) ) {
649
+ return $mail_from_email;
650
+ }
651
+ }
652
+
653
+ if ( is_email( get_option( 'mail_from' ), false ) ) {
654
+ return get_option( 'mail_from' );
655
+ }
656
+
657
+ // If in doubt, return the original value.
658
+ return $orig;
659
+ } // End of wp_mail_smtp_mail_from() function definition.
660
+ endif;
661
+
662
+ if ( ! function_exists( 'wp_mail_smtp_mail_from_name' ) ) :
663
+ /**
664
+ * This function sets the from name value.
665
+ *
666
+ * @param string $orig
667
+ *
668
+ * @return string
669
+ */
670
+ function wp_mail_smtp_mail_from_name( $orig ) {
671
+
672
+ // Only filter if the from name is the default.
673
+ if ( 'WordPress' === $orig ) {
674
+ if (
675
+ defined( 'WPMS_ON' ) && WPMS_ON &&
676
+ defined( 'WPMS_MAIL_FROM_NAME' )
677
+ ) {
678
+ $mail_from_name = WPMS_MAIL_FROM_NAME;
679
+
680
+ if ( ! empty( $mail_from_name ) ) {
681
+ return $mail_from_name;
682
+ }
683
+ }
684
+
685
+ $from_name = get_option( 'mail_from_name' );
686
+ if ( ! empty( $from_name ) && is_string( $from_name ) ) {
687
+ return $from_name;
688
+ }
689
+ }
690
+
691
+ return $orig;
692
+ }
693
+ endif;
694
+
695
+ /**
696
+ * Add a link to Settings page of a plugin on Plugins page.
697
+ *
698
+ * @param array $links
699
+ * @param string $file
700
+ *
701
+ * @return mixed
702
+ */
703
+ function wp_mail_plugin_action_links( $links, $file ) {
704
+
705
+ if ( plugin_basename( __FILE__ ) !== $file ) {
706
+ return $links;
707
+ }
708
+
709
+ $settings_link = '<a href="options-general.php?page=' . plugin_basename( __FILE__ ) . '">' . esc_html__( 'Settings', 'wp-mail-smtp' ) . '</a>';
710
+
711
+ array_unshift( $links, $settings_link );
712
+
713
+ return $links;
714
+ }
715
+
716
+ /**
717
+ * Awesome Motive Notifications.
718
+ *
719
+ * @since 0.11
720
+ */
721
+ function wp_mail_smtp_am_notifications() {
722
+
723
+ $is_hidden = get_option( 'wp_mail_smtp_am_notifications_hidden', '' );
724
+
725
+ if ( 'true' === $is_hidden ) {
726
+ return;
727
+ }
728
+
729
+ if ( ! class_exists( 'WPMS_AM_Notification' ) ) {
730
+ require_once dirname( __FILE__ ) . '/class-wpms-am-notification.php';
731
+ }
732
+
733
+ new WPMS_AM_Notification( 'smtp', WPMS_PLUGIN_VER );
734
+ }
735
+
736
+ add_action( 'plugins_loaded', 'wp_mail_smtp_am_notifications' );
737
+
738
+ /**
739
+ * Check whether the site is using Pepipost or not.
740
+ *
741
+ * @since 0.11
742
+ *
743
+ * @return bool
744
+ */
745
+ function wp_mail_smtp_is_pepipost_active() {
746
+ return apply_filters( 'wp_mail_smtp_options_is_pepipost_active', 'pepipost' === get_option( 'mailer' ) );
747
+ }
748
+
749
+ /**
750
+ * Check the current PHP version and display a notice if on unsupported PHP.
751
+ *
752
+ * @since 0.11
753
+ */
754
+ function wp_mail_smtp_check_php_version() {
755
+
756
+ // Display for admins only.
757
+ if ( ! is_super_admin() ) {
758
+ return;
759
+ }
760
+
761
+ // Display on Dashboard page only.
762
+ if ( isset( $GLOBALS['pagenow'] ) && 'index.php' !== $GLOBALS['pagenow'] ) {
763
+ return;
764
+ }
765
+
766
+ echo '<div class="notice notice-error">' .
767
+ '<p>' .
768
+ sprintf(
769
+ /* translators: %1$s - WP Mail SMTP plugin name; %2$s - opening a link tag; %3$s - closing a link tag. */
770
+ esc_html__(
771
+ 'Your site is running an outdated version of PHP that is no longer supported and may cause issues with %1$s. %2$sRead more%3$s for additional information.',
772
+ 'wp-mail-smtp'
773
+ ),
774
+ '<strong>WP Mail SMTP</strong>',
775
+ '<a href="https://wpforms.com/docs/supported-php-version/" target="_blank">',
776
+ '</a>'
777
+ ) .
778
+ '</p>' .
779
+ '</div>';
780
+ }
781
+
782
+ add_action( 'admin_notices', 'wp_mail_smtp_check_php_version' );
783
+
784
+ // Add an action on phpmailer_init.
785
+ add_action( 'phpmailer_init', 'phpmailer_init_smtp' );
786
+
787
+ if ( ! defined( 'WPMS_ON' ) || ! WPMS_ON ) {
788
+ // Whitelist our options.
789
+ add_filter( 'whitelist_options', 'wp_mail_smtp_whitelist_options' );
790
+ // Add the create pages options.
791
+ add_action( 'admin_menu', 'wp_mail_smtp_menus' );
792
+ // Add an activation hook for this plugin.
793
+ register_activation_hook( __FILE__, 'wp_mail_smtp_activate' );
794
+ // Adds "Settings" link to the Plugins page.
795
+ add_filter( 'plugin_action_links', 'wp_mail_plugin_action_links', 10, 2 );
796
+ }
797
+
798
+ // Add filters to replace the mail from name and email address.
799
+ add_filter( 'wp_mail_from', 'wp_mail_smtp_mail_from' );
800
+ add_filter( 'wp_mail_from_name', 'wp_mail_smtp_mail_from_name' );
801
+
802
+ load_plugin_textdomain( 'wp-mail-smtp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
wp_mail_smtp.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * Plugin Name: WP Mail SMTP
4
- * Version: 1.5.0
5
  * Plugin URI: https://wpforms.com/
6
  * Description: Reconfigures the <code>wp_mail()</code> function to use Gmail/Mailgun/SendGrid/SMTP instead of the default <code>mail()</code> and creates an options page to manage the settings.
7
  * Author: WPForms
@@ -134,7 +134,7 @@ if ( ! function_exists( 'wp_mail_smtp_check_pro_loading_allowed' ) ) {
134
  }
135
 
136
  if ( ! defined( 'WPMS_PLUGIN_VER' ) ) {
137
- define( 'WPMS_PLUGIN_VER', '1.5.0' );
138
  }
139
  if ( ! defined( 'WPMS_PHP_VER' ) ) {
140
  define( 'WPMS_PHP_VER', '5.3.6' );
1
  <?php
2
  /**
3
  * Plugin Name: WP Mail SMTP
4
+ * Version: 1.5.1
5
  * Plugin URI: https://wpforms.com/
6
  * Description: Reconfigures the <code>wp_mail()</code> function to use Gmail/Mailgun/SendGrid/SMTP instead of the default <code>mail()</code> and creates an options page to manage the settings.
7
  * Author: WPForms
134
  }
135
 
136
  if ( ! defined( 'WPMS_PLUGIN_VER' ) ) {
137
+ define( 'WPMS_PLUGIN_VER', '1.5.1' );
138
  }
139
  if ( ! defined( 'WPMS_PHP_VER' ) ) {
140
  define( 'WPMS_PHP_VER', '5.3.6' );