WP Mail SMTP by WPForms - Version 0.11.1

Version Description

Download this release

Release Info

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

Code changes from version 0.10.1 to 0.11.1

.gitignore DELETED
@@ -1 +0,0 @@
1
- .sync-config.cson
README.md DELETED
@@ -1,4 +0,0 @@
1
- WP Mail SMTP
2
- ---
3
-
4
- https://wordpress.org/plugins/wp-mail-smtp/
class-wpms-am-notification.php ADDED
@@ -0,0 +1,526 @@
1
+ <?php
2
+
3
+ /**
4
+ * Awesome Motive Notifications
5
+ *
6
+ * This creates a custom post type (if it doesn't exist) and calls the API to
7
+ * retrieve notifications for this product.
8
+ *
9
+ * @package AwesomeMotive
10
+ * @author Benjamin Rojas
11
+ * @license GPL-2.0+
12
+ * @copyright Copyright (c) 2017, Retyp LLC
13
+ * @version 1.0.0
14
+ */
15
+ class WPMS_AM_Notification {
16
+ /**
17
+ * The api url we are calling.
18
+ *
19
+ * @since 1.0.0
20
+ *
21
+ * @var string
22
+ */
23
+ public $api_url = 'https://api.awesomemotive.com/v1/notification/';
24
+
25
+ /**
26
+ * A unique slug for this plugin.
27
+ * (Not the WordPress plugin slug)
28
+ *
29
+ * @since 1.0.0
30
+ *
31
+ * @var string
32
+ */
33
+ public $plugin;
34
+
35
+ /**
36
+ * The current plugin version.
37
+ *
38
+ * @since 1.0.0
39
+ *
40
+ * @var string
41
+ */
42
+ public $plugin_version;
43
+
44
+ /**
45
+ * The list of installed plugins.
46
+ *
47
+ * @since 1.0.0
48
+ *
49
+ * @var array
50
+ */
51
+ public $plugin_list = array();
52
+
53
+ /**
54
+ * The list of installed themes.
55
+ *
56
+ * @since 1.0.0
57
+ *
58
+ * @var string
59
+ */
60
+ public $theme_list = array();
61
+
62
+ /**
63
+ * Flag if a notice has been registered.
64
+ *
65
+ * @since 1.0.0
66
+ *
67
+ * @var bool
68
+ */
69
+ public static $registered = false;
70
+
71
+ /**
72
+ * Construct.
73
+ *
74
+ * @since 1.0.0
75
+ *
76
+ * @param string $plugin The plugin slug.
77
+ * @param mixed $version The version of the plugin.
78
+ */
79
+ public function __construct( $plugin = '', $version = 0 ) {
80
+ $this->plugin = $plugin;
81
+ $this->plugin_version = $version;
82
+
83
+ add_action( 'init', array( $this, 'custom_post_type' ) );
84
+ add_action( 'admin_init', array( $this, 'get_remote_notifications' ), 100 );
85
+ add_action( 'admin_notices', array( $this, 'display_notifications' ) );
86
+ add_action( 'wp_ajax_am_notification_dismiss', array( $this, 'dismiss_notification' ) );
87
+ }
88
+
89
+ /**
90
+ * Registers a custom post type.
91
+ *
92
+ * @since 1.0.0
93
+ */
94
+ public function custom_post_type() {
95
+ register_post_type( 'amn_' . $this->plugin, array(
96
+ 'supports' => false,
97
+ ) );
98
+ }
99
+
100
+ /**
101
+ * Retrieve the remote notifications if the time has expired.
102
+ *
103
+ * @since 1.0.0
104
+ */
105
+ public function get_remote_notifications() {
106
+ if ( ! current_user_can( apply_filters( 'am_notifications_display', 'manage_options' ) ) ) {
107
+ return;
108
+ }
109
+
110
+ $last_checked = get_option( '_amn_' . $this->plugin . '_last_checked', strtotime( '-1 week' ) );
111
+
112
+ if ( $last_checked < strtotime( 'today midnight' ) ) {
113
+ $plugin_notifications = $this->get_plugin_notifications( 1 );
114
+ $notification_id = null;
115
+
116
+ if ( ! empty( $plugin_notifications ) ) {
117
+ // Unset it from the array.
118
+ $notification = $plugin_notifications[0];
119
+ $notification_id = get_post_meta( $notification->ID, 'notification_id', true );
120
+ }
121
+
122
+ $response = wp_remote_retrieve_body( wp_remote_post( $this->api_url, array(
123
+ 'body' => array(
124
+ 'slug' => $this->plugin,
125
+ 'version' => $this->plugin_version,
126
+ 'last_notification' => $notification_id,
127
+ 'plugins' => $this->get_plugins_list(),
128
+ 'themes' => $this->get_themes_list(),
129
+ ),
130
+ ) ) );
131
+
132
+ $data = json_decode( $response );
133
+
134
+ if ( ! empty( $data->id ) ) {
135
+ $notifications = array();
136
+
137
+ foreach ( (array) $data->slugs as $slug ) {
138
+ $notifications = array_merge(
139
+ $notifications,
140
+ (array) get_posts(
141
+ array(
142
+ 'post_type' => 'amn_' . $slug,
143
+ 'post_status' => 'all',
144
+ 'meta_key' => 'notification_id',
145
+ 'meta_value' => $data->id,
146
+ )
147
+ )
148
+ );
149
+ }
150
+
151
+ if ( empty( $notifications ) ) {
152
+ $new_notification_id = wp_insert_post( array(
153
+ 'post_content' => wp_kses_post( $data->content ),
154
+ 'post_type' => 'amn_' . $this->plugin,
155
+ ) );
156
+
157
+ update_post_meta( $new_notification_id, 'notification_id', absint( $data->id ) );
158
+ update_post_meta( $new_notification_id, 'type', sanitize_text_field( trim( $data->type ) ) );
159
+ update_post_meta( $new_notification_id, 'dismissable', (bool) $data->dismissible ? 1 : 0 );
160
+ update_post_meta( $new_notification_id, 'location', function_exists( 'wp_json_encode' ) ? wp_json_encode( $data->location ) : json_encode( $data->location ) );
161
+ update_post_meta( $new_notification_id, 'plugins', function_exists( 'wp_json_encode' ) ? wp_json_encode( $data->plugins ) : json_encode( $data->plugins ) );
162
+ update_post_meta( $new_notification_id, 'theme', sanitize_text_field( trim( $data->theme ) ) );
163
+ update_post_meta( $new_notification_id, 'version', sanitize_text_field( trim( $data->version ) ) );
164
+ update_post_meta( $new_notification_id, 'viewed', 0 );
165
+ update_post_meta( $new_notification_id, 'expiration', $data->expiration ? absint( $data->expiration ) : false );
166
+ update_post_meta( $new_notification_id, 'plans', function_exists( 'wp_json_encode' ) ? wp_json_encode( $data->plans ) : json_encode( $data->plans ) );
167
+ }
168
+ }
169
+
170
+ // Possibly revoke notifications.
171
+ if ( ! empty( $data->revoked ) ) {
172
+ $this->revoke_notifications( $data->revoked );
173
+ }
174
+
175
+ // Set the option now so we can't run this again until after 24 hours.
176
+ update_option( '_amn_' . $this->plugin . '_last_checked', strtotime( 'today midnight' ) );
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Get local plugin notifications that have already been set.
182
+ *
183
+ * @since 1.0.0
184
+ *
185
+ * @param integer $limit Set the limit for how many posts to retrieve.
186
+ * @param array $args Any top-level arguments to add to the array.
187
+ *
188
+ * @return WP_Post[] WP_Post that match the query.
189
+ */
190
+ public function get_plugin_notifications( $limit = -1, $args = array() ) {
191
+ return get_posts(
192
+ array(
193
+ 'showposts' => $limit,
194
+ 'post_type' => 'amn_' . $this->plugin,
195
+ ) + $args
196
+ );
197
+ }
198
+
199
+ /**
200
+ * Retrieve a list of plugins that are currently installed.
201
+ *
202
+ * @since 1.0.0
203
+ *
204
+ * @return array An array of plugins that are currently installed.
205
+ */
206
+ public function get_plugins_list() {
207
+ if ( ! empty( $this->plugin_list ) ) {
208
+ return $this->plugin_list;
209
+ }
210
+
211
+ if ( ! function_exists( 'get_plugins' ) ) {
212
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
213
+ }
214
+
215
+ $plugins = get_plugins();
216
+
217
+ foreach ( $plugins as $slug => $plugin ) {
218
+ $this->plugin_list[ $slug ] = array(
219
+ 'slug' => $slug,
220
+ 'name' => $plugin['Name'],
221
+ 'version' => $plugin['Version'],
222
+ 'active' => is_plugin_active( $slug ),
223
+ );
224
+ }
225
+
226
+ return $this->plugin_list;
227
+ }
228
+
229
+ /**
230
+ * Retrieve a list of themes that are currently installed.
231
+ *
232
+ * @since 1.0.0
233
+ *
234
+ * @return array An array of themes that are currently installed.
235
+ */
236
+ public function get_themes_list() {
237
+ if ( ! empty( $this->theme_list ) ) {
238
+ return $this->theme_list;
239
+ }
240
+
241
+ $themes = wp_get_themes();
242
+
243
+ foreach ( $themes as $slug => $theme ) {
244
+ $this->theme_list[ $slug ] = array(
245
+ 'slug' => $slug,
246
+ 'name' => $theme->Name,
247
+ 'version' => $theme->Version,
248
+ 'active' => (string) wp_get_theme() === $theme->Name,
249
+ );
250
+ }
251
+
252
+ return $this->theme_list;
253
+ }
254
+
255
+ /**
256
+ * Display any notifications that should be displayed.
257
+ *
258
+ * @since 1.0.0
259
+ */
260
+ public function display_notifications() {
261
+ if ( ! current_user_can( apply_filters( 'am_notifications_display', 'manage_options' ) ) ) {
262
+ return;
263
+ }
264
+
265
+ $plugin_notifications = $this->get_plugin_notifications( -1, array(
266
+ 'post_status' => 'all',
267
+ 'meta_key' => 'viewed',
268
+ 'meta_value' => '0',
269
+ ) );
270
+
271
+ $plugin_notifications = $this->validate_notifications( $plugin_notifications );
272
+
273
+ if ( ! empty( $plugin_notifications ) && ! self::$registered ) {
274
+ foreach ( $plugin_notifications as $notification ) {
275
+ $dismissable = get_post_meta( $notification->ID, 'dismissable', true );
276
+ $type = get_post_meta( $notification->ID, 'type', true );
277
+ ?>
278
+ <div class="am-notification am-notification-<?php echo $notification->ID; ?> notice notice-<?php echo $type; ?><?php echo $dismissable ? ' is-dismissible' : ''; ?>">
279
+ <?php echo $notification->post_content; ?>
280
+ </div>
281
+ <script type="text/javascript">
282
+ jQuery(document).ready(function ($) {
283
+ $(document).on('click', '.am-notification-<?php echo $notification->ID; ?> button.notice-dismiss', function (event) {
284
+ $.post(ajaxurl, {
285
+ action: 'am_notification_dismiss',
286
+ notification_id: '<?php echo $notification->ID; ?>'
287
+ });
288
+ });
289
+ });
290
+ </script>
291
+ <?php
292
+ }
293
+
294
+ self::$registered = true;
295
+ }
296
+ }
297
+
298
+ /**
299
+ * Validate the notifications before displaying them.
300
+ *
301
+ * @since 1.0.0
302
+ *
303
+ * @param array $plugin_notifications An array of plugin notifications.
304
+ *
305
+ * @return array A filtered array of plugin notifications.
306
+ */
307
+ public function validate_notifications( $plugin_notifications ) {
308
+ global $pagenow;
309
+
310
+ foreach ( $plugin_notifications as $key => $notification ) {
311
+ // Location validation.
312
+ $location = (array) json_decode( get_post_meta( $notification->ID, 'location', true ) );
313
+ $continue = false;
314
+ if ( ! in_array( 'everywhere', $location, true ) ) {
315
+ if ( in_array( 'index.php', $location, true ) && 'index.php' === $pagenow ) {
316
+ $continue = true;
317
+ }
318
+
319
+ if ( in_array( 'plugins.php', $location, true ) && 'plugins.php' === $pagenow ) {
320
+ $continue = true;
321
+ }
322
+
323
+ if ( ! $continue ) {
324
+ unset( $plugin_notifications[ $key ] );
325
+ }
326
+ }
327
+
328
+ // Plugin validation (OR conditional).
329
+ $plugins = (array) json_decode( get_post_meta( $notification->ID, 'plugins', true ) );
330
+ $continue = false;
331
+ if ( ! empty( $plugins ) ) {
332
+ foreach ( $plugins as $plugin ) {
333
+ if ( is_plugin_active( $plugin ) ) {
334
+ $continue = true;
335
+ }
336
+ }
337
+
338
+ if ( ! $continue ) {
339
+ unset( $plugin_notifications[ $key ] );
340
+ }
341
+ }
342
+
343
+ // Theme validation.
344
+ $theme = get_post_meta( $notification->ID, 'theme', true );
345
+ $continue = (string) wp_get_theme() === $theme;
346
+
347
+ if ( ! empty( $theme ) && ! $continue ) {
348
+ unset( $plugin_notifications[ $key ] );
349
+ }
350
+
351
+ // Version validation.
352
+ $version = get_post_meta( $notification->ID, 'version', true );
353
+ $continue = false;
354
+ if ( ! empty( $version ) ) {
355
+ if ( version_compare( $this->plugin_version, $version, '<=' ) ) {
356
+ $continue = true;
357
+ }
358
+
359
+ if ( ! $continue ) {
360
+ unset( $plugin_notifications[ $key ] );
361
+ }
362
+ }
363
+
364
+ // Expiration validation.
365
+ $expiration = get_post_meta( $notification->ID, 'expiration', true );
366
+ $continue = false;
367
+ if ( ! empty( $expiration ) ) {
368
+ if ( $expiration > time() ) {
369
+ $continue = true;
370
+ }
371
+
372
+ if ( ! $continue ) {
373
+ unset( $plugin_notifications[ $key ] );
374
+ }
375
+ }
376
+
377
+ // Plan validation.
378
+ $plans = (array) json_decode( get_post_meta( $notification->ID, 'plans', true ) );
379
+ $continue = false;
380
+ if ( ! empty( $plans ) ) {
381
+ $level = $this->get_plan_level();
382
+ if ( in_array( $level, $plans, true ) ) {
383
+ $continue = true;
384
+ }
385
+
386
+ if ( ! $continue ) {
387
+ unset( $plugin_notifications[ $key ] );
388
+ }
389
+ }
390
+ }
391
+
392
+ return $plugin_notifications;
393
+ }
394
+
395
+ /**
396
+ * Grab the current plan level.
397
+ *
398
+ * @since 1.0.0
399
+ *
400
+ * @return string The current plan level.
401
+ */
402
+ public function get_plan_level() {
403
+ // Prepare variables.
404
+ $key = '';
405
+ $level = '';
406
+ $option = false;
407
+ switch ( $this->plugin ) {
408
+ case 'wpforms' :
409
+ $option = get_option( 'wpforms_license' );
410
+ $key = is_array( $option ) && isset( $option['key'] ) ? $option['key'] : '';
411
+ $level = is_array( $option ) && isset( $option['type'] ) ? $option['type'] : '';
412
+
413
+ // Possibly check for a constant.
414
+ if ( empty( $key ) && defined( 'WPFORMS_LICENSE_KEY' ) ) {
415
+ $key = WPFORMS_LICENSE_KEY;
416
+ }
417
+ break;
418
+ case 'mi' :
419
+ $option = get_option( 'monsterinsights_license' );
420
+ $key = is_array( $option ) && isset( $option['key'] ) ? $option['key'] : '';
421
+ $level = is_array( $option ) && isset( $option['type'] ) ? $option['type'] : '';
422
+
423
+ // Possibly check for a constant.
424
+ if ( empty( $key ) && defined( 'MONSTERINSIGHTS_LICENSE_KEY' ) && is_string( MONSTERINSIGHTS_LICENSE_KEY ) && strlen( MONSTERINSIGHTS_LICENSE_KEY ) > 10 ) {
425
+ $key = MONSTERINSIGHTS_LICENSE_KEY;
426
+ }
427
+ break;
428
+ case 'sol' :
429
+ $option = get_option( 'soliloquy' );
430
+ $key = is_array( $option ) && isset( $option['key'] ) ? $option['key'] : '';
431
+ $level = is_array( $option ) && isset( $option['type'] ) ? $option['type'] : '';
432
+
433
+ // Possibly check for a constant.
434
+ if ( empty( $key ) && defined( 'SOLILOQUY_LICENSE_KEY' ) ) {
435
+ $key = SOLILOQUY_LICENSE_KEY;
436
+ }
437
+ break;
438
+ case 'envira' :
439
+ $option = get_option( 'envira_gallery' );
440
+ $key = is_array( $option ) && isset( $option['key'] ) ? $option['key'] : '';
441
+ $level = is_array( $option ) && isset( $option['type'] ) ? $option['type'] : '';
442
+
443
+ // Possibly check for a constant.
444
+ if ( empty( $key ) && defined( 'ENVIRA_LICENSE_KEY' ) ) {
445
+ $key = ENVIRA_LICENSE_KEY;
446
+ }
447
+ break;
448
+ case 'om' :
449
+ $option = get_option( 'optin_monster_api' );
450
+ $key = is_array( $option ) && isset( $option['api']['apikey'] ) ? $option['api']['apikey'] : '';
451
+
452
+ // Possibly check for a constant.
453
+ if ( empty( $key ) && defined( 'OPTINMONSTER_REST_API_LICENSE_KEY' ) ) {
454
+ $key = OPTINMONSTER_REST_API_LICENSE_KEY;
455
+ }
456
+
457
+ // If the key is still empty, check for the old legacy key.
458
+ if ( empty( $key ) ) {
459
+ $key = is_array( $option ) && isset( $option['api']['key'] ) ? $option['api']['key'] : '';
460
+ }
461
+ break;
462
+ }
463
+
464
+ // Possibly set the level to 'none' if the key is empty and no level has been set.
465
+ if ( empty( $key ) && empty( $level ) ) {
466
+ $level = 'none';
467
+ }
468
+
469
+ // Normalize the level.
470
+ switch ( $level ) {
471
+ case 'bronze' :
472
+ case 'personal' :
473
+ $level = 'basic';
474
+ break;
475
+ case 'silver' :
476
+ case 'multi' :
477
+ $level = 'plus';
478
+ break;
479
+ case 'gold' :
480
+ case 'developer' :
481
+ $level = 'pro';
482
+ break;
483
+ case 'platinum' :
484
+ case 'master' :
485
+ $level = 'ultimate';
486
+ break;
487
+ }
488
+
489
+ // Return the plan level.
490
+ return $level;
491
+ }
492
+
493
+ /**
494
+ * Dismiss the notification via AJAX.
495
+ *
496
+ * @since 1.0.0
497
+ */
498
+ public function dismiss_notification() {
499
+ if ( ! current_user_can( apply_filters( 'am_notifications_display', 'manage_options' ) ) ) {
500
+ die;
501
+ }
502
+
503
+ $notification_id = intval( $_POST['notification_id'] );
504
+ update_post_meta( $notification_id, 'viewed', 1 );
505
+ die;
506
+ }
507
+
508
+ /**
509
+ * Revokes notifications.
510
+ *
511
+ * @since 1.0.0
512
+ *
513
+ * @param array $ids An array of notification IDs to revoke.
514
+ */
515
+ public function revoke_notifications( $ids ) {
516
+ // Loop through each of the IDs and find the post that has it as meta.
517
+ foreach ( (array) $ids as $id ) {
518
+ $notifications = $this->get_plugin_notifications( -1, array( 'post_status' => 'all', 'meta_key' => 'notification_id', 'meta_value' => $id ) );
519
+ if ( $notifications ) {
520
+ foreach ( $notifications as $notification ) {
521
+ update_post_meta( $notification->ID, 'viewed', 1 );
522
+ }
523
+ }
524
+ }
525
+ }
526
+ }
langs/wp_mail_smtp-he_IL.mo → languages/wp-mail-smtp-he_IL.mo RENAMED
File without changes
langs/wp_mail_smtp-ja.mo → languages/wp-mail-smtp-ja.mo RENAMED
File without changes
languages/wp-mail-smtp.pot ADDED
@@ -0,0 +1,195 @@
1
+ # Copyright (C) 2017 WP Mail SMTP
2
+ # This file is distributed under the same license as the WP Mail SMTP package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: WP Mail SMTP\n"
6
+ "MIME-Version: 1.0\n"
7
+ "Content-Type: text/plain; charset=UTF-8\n"
8
+ "Content-Transfer-Encoding: 8bit\n"
9
+ "Language-Team: WPForms <support@wpforms.com>\n"
10
+ "X-Poedit-Basepath: ..\n"
11
+ "X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
12
+ "X-Poedit-SearchPath-0: .\n"
13
+ "X-Poedit-SearchPathExcluded-0: *.js\n"
14
+ "X-Poedit-SourceCharset: UTF-8\n"
15
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
+
17
+ #: wp_mail_smtp.php:238
18
+ msgid "Test mail to %s"
19
+ msgstr ""
20
+
21
+ #: wp_mail_smtp.php:239
22
+ msgid "This is a test email generated by the WP Mail SMTP WordPress plugin."
23
+ msgstr ""
24
+
25
+ #: wp_mail_smtp.php:255
26
+ msgid "Test Message Sent"
27
+ msgstr ""
28
+
29
+ #: wp_mail_smtp.php:256
30
+ msgid "The result was:"
31
+ msgstr ""
32
+
33
+ #: wp_mail_smtp.php:259
34
+ msgid "The full debugging output is shown below:"
35
+ msgstr ""
36
+
37
+ #: wp_mail_smtp.php:262
38
+ msgid "The SMTP debugging output is shown below:"
39
+ msgstr ""
40
+
41
+ #: wp_mail_smtp.php:229, wp_mail_smtp.php:583
42
+ msgid "Send Test"
43
+ msgstr ""
44
+
45
+ #: wp_mail_smtp.php:274, wp_mail_smtp.php:619
46
+ msgid "WP Mail SMTP Settings"
47
+ msgstr ""
48
+
49
+ #: wp_mail_smtp.php:283
50
+ msgid "From Email"
51
+ msgstr ""
52
+
53
+ #: wp_mail_smtp.php:290
54
+ msgid "You can specify the email address that emails should be sent from. If you leave this blank, the default email will be used."
55
+ msgstr ""
56
+
57
+ #: wp_mail_smtp.php:293
58
+ msgid "<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."
59
+ msgstr ""
60
+
61
+ #: wp_mail_smtp.php:302
62
+ msgid "From Name"
63
+ msgstr ""
64
+
65
+ #: wp_mail_smtp.php:308
66
+ msgid "You can specify the name that emails should be sent from. If you leave this blank, the emails will be sent from WordPress."
67
+ msgstr ""
68
+
69
+ #: wp_mail_smtp.php:317, wp_mail_smtp.php:322
70
+ msgid "Mailer"
71
+ msgstr ""
72
+
73
+ #: wp_mail_smtp.php:327
74
+ msgid "Send all WordPress emails via SMTP."
75
+ msgstr ""
76
+
77
+ #: wp_mail_smtp.php:331
78
+ msgid "Use the PHP mail() function to send emails."
79
+ msgstr ""
80
+
81
+ #: wp_mail_smtp.php:337
82
+ msgid "Use Pepipost SMTP to send emails."
83
+ msgstr ""
84
+
85
+ #: wp_mail_smtp.php:343
86
+ msgid "Looking for high inbox delivery? Try Pepipost with easy setup and free emails. Learn more %1$shere%2$s."
87
+ msgstr ""
88
+
89
+ #: wp_mail_smtp.php:358, wp_mail_smtp.php:363
90
+ msgid "Return Path"
91
+ msgstr ""
92
+
93
+ #: wp_mail_smtp.php:368
94
+ msgid "Set the return-path to match the From Email"
95
+ msgstr ""
96
+
97
+ #: wp_mail_smtp.php:372
98
+ msgid "Return Path indicates where non-delivery receipts - or bounce messages - are to be sent."
99
+ msgstr ""
100
+
101
+ #: wp_mail_smtp.php:380, wp_mail_smtp.php:480, wp_mail_smtp.php:556
102
+ msgid "Save Changes"
103
+ msgstr ""
104
+
105
+ #: wp_mail_smtp.php:385
106
+ msgid "SMTP Options"
107
+ msgstr ""
108
+
109
+ #: wp_mail_smtp.php:387
110
+ msgid "These options only apply if you have chosen to send mail by SMTP above."
111
+ msgstr ""
112
+
113
+ #: wp_mail_smtp.php:392
114
+ msgid "SMTP Host"
115
+ msgstr ""
116
+
117
+ #: wp_mail_smtp.php:400, wp_mail_smtp.php:518
118
+ msgid "SMTP Port"
119
+ msgstr ""
120
+
121
+ #: wp_mail_smtp.php:407, wp_mail_smtp.php:411, wp_mail_smtp.php:526, wp_mail_smtp.php:532
122
+ msgid "Encryption"
123
+ msgstr ""
124
+
125
+ #: wp_mail_smtp.php:416, wp_mail_smtp.php:538
126
+ msgid "No encryption."
127
+ msgstr ""
128
+
129
+ #: wp_mail_smtp.php:421, wp_mail_smtp.php:543
130
+ msgid "Use SSL encryption."
131
+ msgstr ""
132
+
133
+ #: wp_mail_smtp.php:426, wp_mail_smtp.php:548
134
+ msgid "Use TLS encryption."
135
+ msgstr ""
136
+
137
+ #: wp_mail_smtp.php:429
138
+ msgid "TLS is not the same as STARTTLS. For most servers SSL is the recommended option."
139
+ msgstr ""
140
+
141
+ #: wp_mail_smtp.php:434, wp_mail_smtp.php:438
142
+ msgid "Authentication"
143
+ msgstr ""
144
+
145
+ #: wp_mail_smtp.php:443
146
+ msgid "No: Do not use SMTP authentication."
147
+ msgstr ""
148
+
149
+ #: wp_mail_smtp.php:448
150
+ msgid "Yes: Use SMTP authentication."
151
+ msgstr ""
152
+
153
+ #: wp_mail_smtp.php:452
154
+ msgid "If this is set to no, the values below are ignored."
155
+ msgstr ""
156
+
157
+ #: wp_mail_smtp.php:459, wp_mail_smtp.php:502
158
+ msgid "Username"
159
+ msgstr ""
160
+
161
+ #: wp_mail_smtp.php:467, wp_mail_smtp.php:510
162
+ msgid "Password"
163
+ msgstr ""
164
+
165
+ #: wp_mail_smtp.php:473
166
+ msgid "This is in plain text because it must not be stored encrypted."
167
+ msgstr ""
168
+
169
+ #: wp_mail_smtp.php:487
170
+ msgid "Pepipost SMTP Options"
171
+ msgstr ""
172
+
173
+ #: wp_mail_smtp.php:493
174
+ msgid "You need to signup on %s to get the SMTP username/password."
175
+ msgstr ""
176
+
177
+ #: wp_mail_smtp.php:565
178
+ msgid "Send a Test Email"
179
+ msgstr ""
180
+
181
+ #: wp_mail_smtp.php:573
182
+ msgid "To"
183
+ msgstr ""
184
+
185
+ #: wp_mail_smtp.php:577
186
+ msgid "Type an email address here and then click Send Test to generate a test email."
187
+ msgstr ""
188
+
189
+ #: wp_mail_smtp.php:619
190
+ msgid "WP Mail SMTP"
191
+ msgstr ""
192
+
193
+ #: wp_mail_smtp.php:725
194
+ msgid "Settings"
195
+ msgstr ""
readme.txt CHANGED
@@ -1,12 +1,12 @@
1
=== WP Mail SMTP by WPForms ===
2
- Contributors: wpforms, smub, jaredatch
3
Donate link: https://wpforms.com/
4
Tags: mail, smtp, wp_mail, mailer, phpmailer
5
Requires at least: 2.7
6
- Tested up to: 4.7
7
- Stable tag: 0.10.1
8
9
- The most popular SMTP plugin on WordPress.org. Trusted by over 600k sites.
10
11
== Description ==
12
@@ -28,7 +28,7 @@ WP Mail SMTP plugin works with all major email services such as Gmail, Yahoo, Ou
28
29
The goal of WP Mail SMTP plugin is to help fix the common "WordPress not sending an email issue".
30
31
- Often times an email sent out by your WordPress site either lands in the spam folder or get completely rejected by popular email providers.
32
33
SMTP (Simple Mail Transfer Protocol) is the industry standard for sending emails. WP Mail SMTP helps you use proper authentication which increases email deliverability.
34
@@ -49,9 +49,6 @@ If you like this plugin, then consider checking out our other projects:
49
50
Visit <a href="http://www.wpbeginner.com/" rel="friend" title="WPBeginner">WPBeginner</a> to learn from our <a href="http://www.wpbeginner.com/category/wp-tutorials/" rel="friend" title="WordPress Tutorials">WordPress Tutorials</a> and find out about other <a href="http://www.wpbeginner.com/category/plugins/" rel="friend" title="Best WordPress Plugins">best WordPress plugins</a>.
51
52
-
53
-
54
-
55
== Installation ==
56
57
1. Install WP Mail SMTP by WPForms either via the WordPress.org plugin repository or by uploading the files to your server. (See instructions on <a href="http://www.wpbeginner.com/beginners-guide/step-by-step-guide-to-install-a-wordpress-plugin-for-beginners/" rel="friend">how to install a WordPress plugin</a>)
@@ -96,6 +93,20 @@ By all means please contact us to discuss features or options you'd like to see
96
97
== Changelog ==
98
99
= 0.10.1 =
100
* Addition of Pepipost and cleanup of admin page.
101
@@ -232,4 +243,4 @@ Minor bugfix correcting the Settings link bug introduced in 0.8.4. Very low prio
232
Minor bugfix for users using constants. Another very low priority upgrade. Apologies for the version creep.
233
234
= 0.8.3 =
235
- Minor bugfix for users using constants. Very low priority upgrade.
1
=== WP Mail SMTP by WPForms ===
2
+ Contributors: wpforms, smub, jaredatch, slaFFik
3
Donate link: https://wpforms.com/
4
Tags: mail, smtp, wp_mail, mailer, phpmailer
5
Requires at least: 2.7
6
+ Tested up to: 4.8
7
+ Stable tag: trunk
8
9
+ The most popular WordPress SMTP and PHP Mailer plugin. Trusted by over 700k sites.
10
11
== Description ==
12
28
29
The goal of WP Mail SMTP plugin is to help fix the common "WordPress not sending an email issue".
30
31
+ Often times an email sent out by your WordPress site either lands in the spam folder or get completely rejected by popular email providers.
32
33
SMTP (Simple Mail Transfer Protocol) is the industry standard for sending emails. WP Mail SMTP helps you use proper authentication which increases email deliverability.
34
49
50
Visit <a href="http://www.wpbeginner.com/" rel="friend" title="WPBeginner">WPBeginner</a> to learn from our <a href="http://www.wpbeginner.com/category/wp-tutorials/" rel="friend" title="WordPress Tutorials">WordPress Tutorials</a> and find out about other <a href="http://www.wpbeginner.com/category/plugins/" rel="friend" title="Best WordPress Plugins">best WordPress plugins</a>.
51
52
== Installation ==
53
54
1. Install WP Mail SMTP by WPForms either via the WordPress.org plugin repository or by uploading the files to your server. (See instructions on <a href="http://www.wpbeginner.com/beginners-guide/step-by-step-guide-to-install-a-wordpress-plugin-for-beginners/" rel="friend">how to install a WordPress plugin</a>)
93
94
== Changelog ==
95
96
+ = [0.11.1] - 2017-10-30 =
97
+ * Older PHP compatibility fix.
98
+
99
+ = [0.11] - 2017-10-30 =
100
+ * Added: Helper description to Return Path option.
101
+ * Added: Filter `wp_mail_smtp_admin_test_email_smtp_debug` to increase the debug message verbosity.
102
+ * Added: PHP 5.2 notice.
103
+ * Changed: Localization fixes, proper locale name.
104
+ * Changed: Code style improvements and optimizations for both HTML and PHP.
105
+ * Changed: Inputs for emails now have a proper type `email`, instead of a generic `text`.
106
+ * Changed: Turn off `$phpmailer->SMTPAutoTLS` when `No encryption` option is set to prevent error while sending emails.
107
+ * Changed: Hide Pepipost for those who are not using it.
108
+ * Changed: WP CLI support improved.
109
+
110
= 0.10.1 =
111
* Addition of Pepipost and cleanup of admin page.
112
243
Minor bugfix for users using constants. Another very low priority upgrade. Apologies for the version creep.
244
245
= 0.8.3 =
246
+ Minor bugfix for users using constants. Very low priority upgrade.
screenshot-1.png DELETED
Binary file
screenshot-2.png DELETED
Binary file
screenshot-3.png DELETED
Binary file
screenshot-4.png DELETED
Binary file
wp_mail_smtp.php CHANGED
@@ -1,12 +1,14 @@
1
<?php
2
- /*
3
- Plugin Name: WP-Mail-SMTP
4
- Version: 0.10.1
5
- Plugin URI: https://wpforms.com/
6
- Description: Reconfigures the wp_mail() function to use SMTP instead of mail() and creates an options page to manage the settings.
7
- Author: WPForms
8
- Author URI: https://wpforms.com/
9
- */
10
11
/**
12
* @author WPForms
@@ -15,6 +17,8 @@ Author URI: https://wpforms.com/
15
* http://www.gnu.org/licenses/gpl.txt
16
*/
17
18
/**
19
* Setting options in wp-config.php
20
*
@@ -22,6 +26,7 @@ Author URI: https://wpforms.com/
22
* constants in wp-config.php. This disables the plugin's admin page and may
23
* improve performance very slightly. Copy the code below into wp-config.php.
24
*/
25
/*
26
define('WPMS_ON', true);
27
define('WPMS_MAIL_FROM', 'From Email');
@@ -36,503 +41,777 @@ define('WPMS_SMTP_USER', 'username'); // SMTP authentication username, only used
36
define('WPMS_SMTP_PASS', 'password'); // SMTP authentication password, only used if WPMS_SMTP_AUTH is true
37
*/
38
39
- // Array of options and their default values
40
- global $wpms_options; // This is horrible, should be cleaned up at some point
41
- $wpms_options = array (
42
- 'mail_from' => '',
43
- 'mail_from_name' => '',
44
- 'mailer' => 'smtp',
45
'mail_set_return_path' => 'false',
46
- 'smtp_host' => 'localhost',
47
- 'smtp_port' => '25',
48
- 'smtp_ssl' => 'none',
49
- 'smtp_auth' => false,
50
- 'smtp_user' => '',
51
- 'smtp_pass' => '',
52
- 'pepipost_user' => '',
53
- 'pepipost_pass' => '',
54
- 'pepipost_port' => '2525',
55
- 'pepipost_ssl' => 'none'
56
);
57
58
-
59
/**
60
* Activation function. This function creates the required options and defaults.
61
*/
62
- if (!function_exists('wp_mail_smtp_activate')) :
63
- function wp_mail_smtp_activate() {
64
65
- global $wpms_options;
66
67
- // Create the required options...
68
- foreach ($wpms_options as $name => $val) {
69
- add_option($name,$val);
70
}
71
-
72
- }
73
endif;
74
75
- if (!function_exists('wp_mail_smtp_whitelist_options')) :
76
- function wp_mail_smtp_whitelist_options($whitelist_options) {
77
78
- global $wpms_options;
79
80
- // Add our options to the array
81
- $whitelist_options['email'] = array_keys($wpms_options);
82
83
- return $whitelist_options;
84
-
85
- }
86
endif;
87
88
- // To avoid any (very unlikely) clashes, check if the function alredy exists
89
- if (!function_exists('phpmailer_init_smtp')) :
90
- // This code is copied, from wp-includes/pluggable.php as at version 2.2.2
91
- function phpmailer_init_smtp($phpmailer) {
92
93
- // If constants are defined, apply those options
94
- if (defined('WPMS_ON') && WPMS_ON) {
95
96
- $phpmailer->Mailer = WPMS_MAILER;
97
98
- if (WPMS_SET_RETURN_PATH)
99
- $phpmailer->Sender = $phpmailer->From;
100
101
- if (WPMS_MAILER == 'smtp') {
102
- $phpmailer->SMTPSecure = WPMS_SSL;
103
- $phpmailer->Host = WPMS_SMTP_HOST;
104
- $phpmailer->Port = WPMS_SMTP_PORT;
105
- if (WPMS_SMTP_AUTH) {
106
- $phpmailer->SMTPAuth = true;
107
- $phpmailer->Username = WPMS_SMTP_USER;
108
- $phpmailer->Password = WPMS_SMTP_PASS;
109
}
110
- }
111
112
- // If you're using contstants, set any custom options here
113
- $phpmailer = apply_filters('wp_mail_smtp_custom_options', $phpmailer);
114
115
}
116
- else {
117
118
- // Check that mailer is not blank, and if mailer=smtp, host is not blank
119
- if ( ! get_option('mailer') || ( get_option('mailer') == 'smtp' && ! get_option('smtp_host') ) ) {
120
- return;
121
- }
122
123
- // If the mailer is pepipost, make sure we have a username and password
124
- if (get_option('mailer') == 'pepipost' && (! get_option('pepipost_user') && ! get_option('pepipost_pass'))) {
125
- return;
126
- }
127
128
- // Set the mailer type as per config above, this overrides the already called isMail method
129
- $phpmailer->Mailer = get_option('mailer');
130
131
- // Set the Sender (return-path) if required
132
- if (get_option('mail_set_return_path'))
133
- $phpmailer->Sender = $phpmailer->From;
134
135
- // Set the SMTPSecure value, if set to none, leave this blank
136
- $phpmailer->SMTPSecure = get_option('smtp_ssl') == 'none' ? '' : get_option('smtp_ssl');
137
138
- // If we're sending via SMTP, set the host
139
- if (get_option('mailer') == "smtp") {
140
141
- // Set the SMTPSecure value, if set to none, leave this blank
142
- $phpmailer->SMTPSecure = get_option('smtp_ssl') == 'none' ? '' : get_option('smtp_ssl');
143
144
- // Set the other options
145
- $phpmailer->Host = get_option('smtp_host');
146
- $phpmailer->Port = get_option('smtp_port');
147
148
- // If we're using smtp auth, set the username & password
149
- if (get_option('smtp_auth') == "true") {
150
- $phpmailer->SMTPAuth = TRUE;
151
- $phpmailer->Username = get_option('smtp_user');
152
- $phpmailer->Password = get_option('smtp_pass');
153
- }
154
- } elseif (get_option('mailer') == 'pepipost') {
155
- // Set the Pepipost settings
156
- $phpmailer->Mailer = 'smtp';
157
- $phpmailer->Host = 'smtp.pepipost.com';
158
- $phpmailer->Port = get_option('pepipost_port');
159
- $phpmailer->SMTPSecure = get_option('pepipost_ssl') == 'none' ? '' : get_option('pepipost_ssl');;
160
- $phpmailer->SMTPAuth = TRUE;
161
- $phpmailer->Username = get_option('pepipost_user');
162
- $phpmailer->Password = get_option('pepipost_pass');
163
- }
164
165
- // You can add your own options here, see the phpmailer documentation for more info:
166
- // http://phpmailer.sourceforge.net/docs/
167
- $phpmailer = apply_filters('wp_mail_smtp_custom_options', $phpmailer);
168
169
170
- // STOP adding options here.
171
172
- }
173
174
- } // End of phpmailer_init_smtp() function definition
175
- endif;
176
177
178
179
- /**
180
- * This function outputs the plugin options page.
181
- */
182
- if (!function_exists('wp_mail_smtp_options_page')) :
183
- // Define the function
184
- function wp_mail_smtp_options_page() {
185
-
186
- // Load the options
187
- global $wpms_options, $phpmailer;
188
-
189
- // Make sure the PHPMailer class has been instantiated
190
- // (copied verbatim from wp-includes/pluggable.php)
191
- // (Re)create it, if it's gone missing
192
- if ( !is_object( $phpmailer ) || !is_a( $phpmailer, 'PHPMailer' ) ) {
193
- require_once ABSPATH . WPINC . '/class-phpmailer.php';
194
- require_once ABSPATH . WPINC . '/class-smtp.php';
195
- $phpmailer = new PHPMailer( true );
196
- }
197
198
- // Send a test mail if necessary
199
- if (isset($_POST['wpms_action']) && $_POST['wpms_action'] == __('Send Test', 'wp_mail_smtp') && is_email($_POST['to'])) {
200
201
- check_admin_referer('test-email');
202
203
- // Set up the mail variables
204
- $to = $_POST['to'];
205
- $subject = 'WP Mail SMTP: ' . __('Test mail to ', 'wp_mail_smtp') . $to;
206
- $message = __('This is a test email generated by the WP Mail SMTP WordPress plugin.', 'wp_mail_smtp');
207
208
- // Set SMTPDebug to true
209
- $phpmailer->SMTPDebug = true;
210
211
- // Start output buffering to grab smtp debugging output
212
- ob_start();
213
214
- // Send the test mail
215
- $result = wp_mail($to,$subject,$message);
216
217
- // Strip out the language strings which confuse users
218
- //unset($phpmailer->language);
219
- // This property became protected in WP 3.2
220
221
- // Grab the smtp debugging output
222
- $smtp_debug = ob_get_clean();
223
224
- // Output the response
225
- ?>
226
- <div id="message" class="updated fade"><p><strong><?php _e('Test Message Sent', 'wp_mail_smtp'); ?></strong></p>
227
- <p><?php _e('The result was:', 'wp_mail_smtp'); ?></p>
228
- <pre><?php var_dump($result); ?></pre>
229
- <p><?php _e('The full debugging output is shown below:', 'wp_mail_smtp'); ?></p>
230
- <pre><?php var_dump($phpmailer); ?></pre>
231
- <p><?php _e('The SMTP debugging output is shown below:', 'wp_mail_smtp'); ?></p>
232
- <pre><?php echo $smtp_debug ?></pre>
233
- </div>
234
- <?php
235
236
- // Destroy $phpmailer so it doesn't cause issues later
237
- unset($phpmailer);
238
239
}
240
-
241
- ?>
242
- <div class="wrap">
243
- <h2><?php _e('Advanced Email Options', 'wp_mail_smtp'); ?></h2>
244
- <form method="post" action="options.php">
245
- <?php wp_nonce_field('email-options'); ?>
246
-
247
- <table class="optiontable form-table">
248
- <tr valign="top">
249
- <th scope="row"><label for="mail_from"><?php _e('From Email', 'wp_mail_smtp'); ?></label></th>
250
- <td><input name="mail_from" type="text" id="mail_from" value="<?php print(get_option('mail_from')); ?>" size="40" class="regular-text" />
251
- <p class="description"><?php _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'); if(get_option('db_version') < 6124) { print('<br /><span style="color: red;">'); _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'); print('</span>'); } ?></p>
252
- </td>
253
- </tr>
254
- <tr valign="top">
255
- <th scope="row"><label for="mail_from_name"><?php _e('From Name', 'wp_mail_smtp'); ?></label></th>
256
- <td><input name="mail_from_name" type="text" id="mail_from_name" value="<?php print(get_option('mail_from_name')); ?>" size="40" class="regular-text" />
257
- <p class="description"><?php _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'); ?></p>
258
- </td>
259
- </tr>
260
- </table>
261
-
262
-
263
- <table class="optiontable form-table">
264
- <tr valign="top">
265
- <th scope="row"><?php _e('Mailer', 'wp_mail_smtp'); ?> </th>
266
- <td><fieldset><legend class="screen-reader-text"><span><?php _e('Mailer', 'wp_mail_smtp'); ?></span></legend>
267
- <p><input id="mailer_smtp" class="wpms_mailer" type="radio" name="mailer" value="smtp" <?php checked('smtp', get_option('mailer')); ?> />
268
- <label for="mailer_smtp"><?php _e('Send all WordPress emails via SMTP.', 'wp_mail_smtp'); ?></label></p>
269
- <p><input id="mailer_pepipost" class="wpms_mailer" type="radio" name="mailer" value="pepipost" <?php checked('pepipost', get_option('mailer')); ?> />
270
- <label for="mailer_pepipost"><?php _e('Use Pepipost SMTP to send emails.', 'wp_mail_smtp'); ?></label></p>
271
- <p><input id="mailer_mail" class="wpms_mailer" type="radio" name="mailer" value="mail" <?php checked('mail', get_option('mailer')); ?> />
272
- <label for="mailer_mail"><?php _e('Use the PHP mail() function to send emails.', 'wp_mail_smtp'); ?></label></p>
273
- </fieldset>
274
- <p class="description">Looking for high inbox delivery? Try Pepipost with easy setup and free emails. Learn more <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">here</a>.</p>
275
- </td>
276
- </tr>
277
- </table>
278
-
279
-
280
- <table class="optiontable form-table">
281
- <tr valign="top">
282
- <th scope="row"><?php _e('Return Path', 'wp_mail_smtp'); ?> </th>
283
- <td><fieldset><legend class="screen-reader-text"><span><?php _e('Return Path', 'wp_mail_smtp'); ?></span></legend><label for="mail_set_return_path">
284
- <input name="mail_set_return_path" type="checkbox" id="mail_set_return_path" value="true" <?php checked('true', get_option('mail_set_return_path')); ?> />
285
- <?php _e('Set the return-path to match the From Email'); ?></label>
286
- </fieldset></td>
287
- </tr>
288
- </table>
289
-
290
- <p class="submit"><input type="submit" name="submit" id="submit" class="button-primary" value="<?php _e('Save Changes'); ?>" /></p>
291
-
292
- <div id="wpms_section_smtp" class="wpms_section">
293
- <h3><?php _e('SMTP Options', 'wp_mail_smtp'); ?></h3>
294
- <p><?php _e('These options only apply if you have chosen to send mail by SMTP above.', 'wp_mail_smtp'); ?></p>
295
-
296
- <table class="optiontable form-table">
297
- <tr valign="top">
298
- <th scope="row"><label for="smtp_host"><?php _e('SMTP Host', 'wp_mail_smtp'); ?></label></th>
299
- <td><input name="smtp_host" type="text" id="smtp_host" value="<?php print(get_option('smtp_host')); ?>" size="40" class="regular-text" /></td>
300
- </tr>
301
- <tr valign="top">
302
- <th scope="row"><label for="smtp_port"><?php _e('SMTP Port', 'wp_mail_smtp'); ?></label></th>
303
- <td><input name="smtp_port" type="text" id="smtp_port" value="<?php print(get_option('smtp_port')); ?>" size="6" class="regular-text" /></td>
304
- </tr>
305
- <tr valign="top">
306
- <th scope="row"><?php _e('Encryption', 'wp_mail_smtp'); ?> </th>
307
- <td>
308
- <fieldset>
309
- <legend class="screen-reader-text"><span><?php _e('Encryption', 'wp_mail_smtp'); ?></span></legend>
310
- <input id="smtp_ssl_none" type="radio" name="smtp_ssl" value="none" <?php checked('none', get_option('smtp_ssl')); ?> />
311
- <label for="smtp_ssl_none"><span><?php _e('No encryption.', 'wp_mail_smtp'); ?></span></label><br />
312
- <input id="smtp_ssl_ssl" type="radio" name="smtp_ssl" value="ssl" <?php checked('ssl', get_option('smtp_ssl')); ?> />
313
- <label for="smtp_ssl_ssl"><span><?php _e('Use SSL encryption.', 'wp_mail_smtp'); ?></span></label><br />
314
- <input id="smtp_ssl_tls" type="radio" name="smtp_ssl" value="tls" <?php checked('tls', get_option('smtp_ssl')); ?> />
315
- <label for="smtp_ssl_tls"><span><?php _e('Use TLS encryption.', 'wp_mail_smtp'); ?></span></label>
316
- <p class="description"><?php esc_html_e('TLS is not the same as STARTTLS. For most servers SSL is the recommended option.'); ?></p>
317
- </td>
318
- </tr>
319
- <tr valign="top">
320
- <th scope="row"><?php _e('Authentication', 'wp_mail_smtp'); ?> </th>
321
- <td>
322
- <fieldset>
323
- <legend class="screen-reader-text"><span><?php _e('Authentication', 'wp_mail_smtp'); ?></span></legend>
324
- <input id="smtp_auth_false" type="radio" name="smtp_auth" value="false" <?php checked('false', get_option('smtp_auth')); ?> />
325
- <label for="smtp_auth_false"><span><?php _e('No: Do not use SMTP authentication.', 'wp_mail_smtp'); ?></span></label><br />
326
- <input id="smtp_auth_true" type="radio" name="smtp_auth" value="true" <?php checked('true', get_option('smtp_auth')); ?> />
327
- <label for="smtp_auth_true"><span><?php _e('Yes: Use SMTP authentication.', 'wp_mail_smtp'); ?></span></label><br />
328
- <p class="description"><?php _e('If this is set to no, the values below are ignored.', 'wp_mail_smtp'); ?></p>
329
- </fieldset>
330
- </td>
331
- </tr>
332
- <tr valign="top">
333
- <th scope="row"><label for="smtp_user"><?php _e('Username', 'wp_mail_smtp'); ?></label></th>
334
- <td><input name="smtp_user" type="text" id="smtp_user" value="<?php print(get_option('smtp_user')); ?>" size="40" class="code" /></td>
335
- </tr>
336
- <tr valign="top">
337
- <th scope="row"><label for="smtp_pass"><?php _e('Password', 'wp_mail_smtp'); ?></label></th>
338
- <td>
339
- <input name="smtp_pass" type="text" id="smtp_pass" value="<?php print(get_option('smtp_pass')); ?>" size="40" class="code" />
340
- <p class="description"><?php printf(esc_html__('This is in plain text because it must be stored encrypted. For more information, click %1$shere%2$s'), '<a href="">', '</a>'); ?>.</p>
341
- </td>
342
- </tr>
343
- </table>
344
-
345
- <p class="submit"><input type="submit" name="submit" id="submit" class="button-primary" value="<?php _e('Save Changes'); ?>" /></p>
346
- </div><!-- #wpms_section_smtp -->
347
-
348
- <div id="wpms_section_pepipost" class="wpms_section">
349
- <h3><?php _e('Pepipost SMTP Options', 'wp_mail_smtp'); ?></h3>
350
- <p>You need to signup on <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> to get the SMTP username/password. Refer this <a href="http://support.pepipost.com/knowledge_base/topics/wp-mail-smtp?utm_source=WordPress&utm_campaign=Plugins&utm_medium=wp_mail_smtp&utm_term=organic" target="_blank">doc</a> for more help.</p>
351
- <table class="optiontable form-table">
352
- <tr valign="top">
353
- <th scope="row"><label for="pepipost_user"><?php _e('Username', 'wp_mail_smtp'); ?></label></th>
354
- <td><input name="pepipost_user" type="text" id="pepipost_user" value="<?php print(get_option('pepipost_user')); ?>" size="40" class="code" /></td>
355
- </tr>
356
- <tr valign="top">
357
- <th scope="row"><label for="pepipost_pass"><?php _e('Password', 'wp_mail_smtp'); ?></label></th>
358
- <td><input name="pepipost_pass" type="text" id="pepipost_pass" value="<?php print(get_option('pepipost_pass')); ?>" size="40" class="code" /></td>
359
- </tr>
360
- <tr valign="top">
361
- <th scope="row"><label for="pepipost_port"><?php _e('SMTP Port', 'wp_mail_smtp'); ?></label></th>
362
- <td><input name="pepipost_port" type="text" id="pepipost_port" value="<?php print(get_option('pepipost_port')); ?>" size="6" class="regular-text" /></td>
363
- </tr>
364
- <tr valign="top">
365
- <th scope="row"><?php _e('Encryption', 'wp_mail_smtp'); ?> </th>
366
- <td>
367
- <fieldset>
368
- <legend class="screen-reader-text">
369
- <span>
370
- <?php _e('Encryption', 'wp_mail_smtp'); ?>
371
- </span>
372
- </legend>
373
- <input id="pepipost_ssl_none" type="radio" name="pepipost_ssl" value="none" <?php checked('none', get_option('pepipost_ssl')); ?> />
374
- <label for="pepipost_ssl_none"><span><?php _e('No encryption.', 'wp_mail_smtp'); ?></span></label><br />
375
- <input id="pepipost_ssl_ssl" type="radio" name="pepipost_ssl" value="ssl" <?php checked('ssl', get_option('pepipost_ssl')); ?> />
376
- <label for="pepipost_ssl_ssl"><span><?php _e('Use SSL encryption.', 'wp_mail_smtp'); ?></span></label><br />
377
- <input id="pepipost_ssl_tls" type="radio" name="pepipost_ssl" value="tls" <?php checked('tls', get_option('pepipost_ssl')); ?> />
378
- <label for="pepipost_ssl_tls"><span><?php _e('Use TLS encryption.', 'wp_mail_smtp'); ?></span></label>
379
- </td>
380
- </tr>
381
- </table>
382
-
383
- <p class="submit"><input type="submit" name="submit" id="submit" class="button-primary" value="<?php _e('Save Changes'); ?>" /></p>
384
- </div><!-- #wpms_section_pepipost -->
385
-
386
-
387
- <input type="hidden" name="action" value="update" />
388
- </p>
389
- <input type="hidden" name="option_page" value="email">
390
- </form>
391
-
392
- <h3><?php _e('Send a Test Email', 'wp_mail_smtp'); ?></h3>
393
-
394
- <form method="POST" action="options-general.php?page=<?php echo plugin_basename(__FILE__); ?>">
395
- <?php wp_nonce_field('test-email'); ?>
396
- <table class="optiontable form-table">
397
- <tr valign="top">
398
- <th scope="row"><label for="to"><?php _e('To', 'wp_mail_smtp'); ?></label></th>
399
- <td><input name="to" type="text" id="to" value="" size="40" class="code" />
400
- <p class="description"><?php _e('Type an email address here and then click Send Test to generate a test email.', 'wp_mail_smtp'); ?></p>
401
- </td>
402
- </tr>
403
- </table>
404
- <p class="submit"><input type="submit" name="wpms_action" id="wpms_action" class="button-primary" value="<?php _e('Send Test', 'wp_mail_smtp'); ?>" /></p>
405
- </form>
406
-
407
- <script type="text/javascript">
408
- var wpmsOnMailerChange = function(mailer) {
409
- // Hide all the mailer forms
410
- jQuery('.wpms_section').hide()
411
- // Show the target mailer form
412
- jQuery('#wpms_section_' + mailer).show()
413
- }
414
- jQuery(document).ready(function(){
415
- // Call wpmsOnMailerChange() on startup with the current mailer
416
- wpmsOnMailerChange(jQuery('input.wpms_mailer:checked').val())
417
-
418
- // Watch the mailer for any changes
419
- jQuery('input.wpms_mailer').on('change', function(e) {
420
- // Call the wpmsOnMailerChange() handler, passing the value of the newly
421
- // selected mailer
422
- wpmsOnMailerChange(jQuery(e.target).val())
423
- })
424
- })
425
- </script>
426
-
427
- </div>
428
- <?php
429
-
430
- } // End of wp_mail_smtp_options_page() function definition
431
endif;
432
433
-
434
/**
435
- * This function adds the required page (only 1 at the moment).
436
*/
437
- if (!function_exists('wp_mail_smtp_menus')) :
438
- function wp_mail_smtp_menus() {
439
440
- if (function_exists('add_submenu_page')) {
441
- add_options_page(__('Advanced Email Options', 'wp_mail_smtp'),__('Email', 'wp_mail_smtp'),'manage_options',__FILE__,'wp_mail_smtp_options_page');
442
}
443
444
- } // End of wp_mail_smtp_menus() function definition
445
- endif;
446
447
448
/**
449
- * This function sets the from email value
450
*/
451
- if (!function_exists('wp_mail_smtp_mail_from')) :
452
- function wp_mail_smtp_mail_from ($orig) {
453
-
454
- // This is copied from pluggable.php lines 348-354 as at revision 10150
455
- // http://trac.wordpress.org/browser/branches/2.7/wp-includes/pluggable.php#L348
456
-
457
- // Get the site domain and get rid of www.
458
- $sitename = strtolower( $_SERVER['SERVER_NAME'] );
459
- if ( substr( $sitename, 0, 4 ) == 'www.' ) {
460
- $sitename = substr( $sitename, 4 );
461
- }
462
-
463
- $default_from = 'wordpress@' . $sitename;
464
- // End of copied code
465
466
- // If the from email is not the default, return it unchanged
467
- if ( $orig != $default_from ) {
468
- return $orig;
469
}
470
471
- if (defined('WPMS_ON') && WPMS_ON) {
472
- if (defined('WPMS_MAIL_FROM') && WPMS_MAIL_FROM != false)
473
- return WPMS_MAIL_FROM;
474
- }
475
- elseif (is_email(get_option('mail_from'), false))
476
- return get_option('mail_from');
477
-
478
- // If in doubt, return the original value
479
- return $orig;
480
481
- } // End of wp_mail_smtp_mail_from() function definition
482
- endif;
483
484
485
/**
486
- * This function sets the from name value
487
*/
488
- if (!function_exists('wp_mail_smtp_mail_from_name')) :
489
- function wp_mail_smtp_mail_from_name ($orig) {
490
-
491
- // Only filter if the from name is the default
492
- if ($orig == 'WordPress') {
493
- if (defined('WPMS_ON') && WPMS_ON) {
494
- if (defined('WPMS_MAIL_FROM_NAME') && WPMS_MAIL_FROM_NAME != false)
495
- return WPMS_MAIL_FROM_NAME;
496
- }
497
- elseif ( get_option('mail_from_name') != "" && is_string(get_option('mail_from_name')) )
498
- return get_option('mail_from_name');
499
- }
500
501
- // If in doubt, return the original value
502
- return $orig;
503
504
- } // End of wp_mail_smtp_mail_from_name() function definition
505
- endif;
506
507
- function wp_mail_plugin_action_links( $links, $file ) {
508
- if ( $file != plugin_basename( __FILE__ ))
509
- return $links;
510
511
- $settings_link = '<a href="options-general.php?page=' . plugin_basename(__FILE__) . '">' . __( 'Settings', 'wp_mail_smtp' ) . '</a>';
512
513
- array_unshift( $links, $settings_link );
514
515
- return $links;
516
- }
517
518
- // Add an action on phpmailer_init
519
- add_action('phpmailer_init','phpmailer_init_smtp');
520
-
521
- if (!defined('WPMS_ON') || !WPMS_ON) {
522
- // Whitelist our options
523
- add_filter('whitelist_options', 'wp_mail_smtp_whitelist_options');
524
- // Add the create pages options
525
- add_action('admin_menu','wp_mail_smtp_menus');
526
- // Add an activation hook for this plugin
527
- register_activation_hook(__FILE__,'wp_mail_smtp_activate');
528
- // Adds "Settings" link to the plugin action page
529
- add_filter( 'plugin_action_links', 'wp_mail_plugin_action_links',10,2);
530
}
531
532
- // Add filters to replace the mail from name and emailaddress
533
- add_filter('wp_mail_from','wp_mail_smtp_mail_from');
534
- add_filter('wp_mail_from_name','wp_mail_smtp_mail_from_name');
535
-
536
- load_plugin_textdomain('wp_mail_smtp', false, dirname(plugin_basename(__FILE__)) . '/langs');
537
538
- ?>
1
<?php
2
+ /**
3
+ * Plugin Name: WP Mail SMTP
4
+ * Version: 0.11.1
5
+ * Plugin URI: https://wpforms.com/
6
+ * Description: Reconfigures the wp_mail() function to use SMTP instead of mail() and creates an options page to manage the settings.
7
+ * Author: WPForms
8
+ * Author URI: https://wpforms.com/
9
+ * Text Domain: wp-mail-smtp
10
+ * Domain Path: /languages
11
+ */
12
13
/**
14
* @author WPForms
17
* http://www.gnu.org/licenses/gpl.txt
18
*/
19
20
+ define( 'WPMS_PLUGIN_VER', '0.11.1' );
21
+
22
/**
23
* Setting options in wp-config.php
24
*
26
* constants in wp-config.php. This disables the plugin's admin page and may
27
* improve performance very slightly. Copy the code below into wp-config.php.
28
*/
29
+
30
/*
31
define('WPMS_ON', true);
32
define('WPMS_MAIL_FROM', 'From Email');
41
define('WPMS_SMTP_PASS', 'password'); // SMTP authentication password, only used if WPMS_SMTP_AUTH is true
42
*/
43
44
+ /**
45
+ * Array of options and their default values.
46
+ * This is horrible, should be cleaned up at some point.
47
+ */
48
+ global $wpms_options;
49
+ $wpms_options = array(
50
+ 'mail_from' => '',
51
+ 'mail_from_name' => '',
52
+ 'mailer' => 'smtp',
53
'mail_set_return_path' => 'false',
54
+ 'smtp_host' => 'localhost',
55
+ 'smtp_port' => '25',
56
+ 'smtp_ssl' => 'none',
57
+ 'smtp_auth' => false,
58
+ 'smtp_user' => '',
59
+ 'smtp_pass' => '',
60
+ 'pepipost_user' => '',
61
+ 'pepipost_pass' => '',
62
+ 'pepipost_port' => '2525',
63
+ 'pepipost_ssl' => 'none',
64
);
65
66
/**
67
* Activation function. This function creates the required options and defaults.
68
*/
69
+ if ( ! function_exists( 'wp_mail_smtp_activate' ) ) :
70
+ /**
71
+ * What to do on plugin activation.
72
+ */
73
+ function wp_mail_smtp_activate() {
74
75
+ global $wpms_options;
76
77
+ // Create the required options...
78
+ foreach ( $wpms_options as $name => $val ) {
79
+ add_option( $name, $val );
80
+ }
81
}
82
endif;
83
84
+ if ( ! function_exists( 'wp_mail_smtp_whitelist_options' ) ) :
85
+ /**
86
+ * Whitelist plugin options.
87
+ *
88
+ * @param array $whitelist_options
89
+ *
90
+ * @return mixed
91
+ */
92
+ function wp_mail_smtp_whitelist_options( $whitelist_options ) {
93
94
+ global $wpms_options;
95
96
+ // Add our options to the array.
97
+ $whitelist_options['email'] = array_keys( $wpms_options );
98
99
+ return $whitelist_options;
100
+ }
101
endif;
102
103
+ /**
104
+ * To avoid any (very unlikely) clashes, check if the function already exists.
105
+ */
106
+ if ( ! function_exists( 'phpmailer_init_smtp' ) ) :
107
+ /**
108
+ * This code is copied, from wp-includes/pluggable.php as at version 2.2.2.
109
+ *
110
+ * @param PHPMailer $phpmailer It's passed by reference, so no need to return anything.
111
+ */
112
+ function phpmailer_init_smtp( $phpmailer ) {
113
+ /*
114
+ * If constants are defined, apply them.
115
+ * We should have defined all required constants before using them.
116
+ */
117
+ if (
118
+ defined( 'WPMS_ON' ) && WPMS_ON &&
119
+ defined( 'WPMS_MAILER' )
120
+ ) {
121
+ $phpmailer->Mailer = WPMS_MAILER;
122
+
123
+ if ( defined( 'WPMS_SET_RETURN_PATH' ) && WPMS_SET_RETURN_PATH ) {
124
+ $phpmailer->Sender = $phpmailer->From;
125
+ }
126
127
+ if (
128
+ WPMS_MAILER === 'smtp' &&
129
+ defined( 'WPMS_SSL' ) &&
130
+ defined( 'WPMS_SMTP_HOST' ) &&
131
+ defined( 'WPMS_SMTP_PORT' )
132
+ ) {
133
+ $phpmailer->SMTPSecure = WPMS_SSL;
134
+ $phpmailer->Host = WPMS_SMTP_HOST;
135
+ $phpmailer->Port = WPMS_SMTP_PORT;
136
+
137
+ if (
138
+ defined( 'WPMS_SMTP_AUTH' ) && WPMS_SMTP_AUTH &&
139
+ defined( 'WPMS_SMTP_USER' ) &&
140
+ defined( 'WPMS_SMTP_PASS' )
141
+ ) {
142
+ $phpmailer->SMTPAuth = true;
143
+ $phpmailer->Username = WPMS_SMTP_USER;
144
+ $phpmailer->Password = WPMS_SMTP_PASS;
145
+ }
146
+ }
147
+ } else {
148
+ $option_mailer = get_option( 'mailer' );
149
+ $option_smtp_host = get_option( 'smtp_host' );
150
+ $option_smtp_ssl = get_option( 'smtp_ssl' );
151
+
152
+ // Check that mailer is not blank, and if mailer=smtp, host is not blank.
153
+ if (
154
+ ! $option_mailer ||
155
+ ( 'smtp' === $option_mailer && ! $option_smtp_host )
156
+ ) {
157
+ return;
158
+ }
159
160
+ // If the mailer is pepipost, make sure we have a username and password.
161
+ if ( 'pepipost' === $option_mailer && ( ! get_option( 'pepipost_user' ) && ! get_option( 'pepipost_pass' ) ) ) {
162
+ return;
163
+ }
164
165
+ // Set the mailer type as per config above, this overrides the already called isMail method.
166
+ $phpmailer->Mailer = $option_mailer;
167
168
+ // Set the Sender (return-path) if required.
169
+ if ( get_option( 'mail_set_return_path' ) ) {
170
+ $phpmailer->Sender = $phpmailer->From;
171
}
172
173
+ // Set the SMTPSecure value, if set to none, leave this blank.
174
+ $phpmailer->SMTPSecure = $option_smtp_ssl;
175
+ if ( 'none' === $option_smtp_ssl ) {
176
+ $phpmailer->SMTPSecure = '';
177
+ $phpmailer->SMTPAutoTLS = false;
178
+ }
179
180
+ // If we're sending via SMTP, set the host.
181
+ if ( 'smtp' === $option_mailer ) {
182
+ // Set the other options.
183
+ $phpmailer->Host = $option_smtp_host;
184
+ $phpmailer->Port = get_option( 'smtp_port' );
185
+
186
+ // If we're using smtp auth, set the username & password.
187
+ if ( get_option( 'smtp_auth' ) === 'true' ) {
188
+ $phpmailer->SMTPAuth = true;
189
+ $phpmailer->Username = get_option( 'smtp_user' );
190
+ $phpmailer->Password = get_option( 'smtp_pass' );
191
+ }
192
+ } elseif ( 'pepipost' === $option_mailer ) {
193
+ // Set the Pepipost settings.
194
+ $phpmailer->Mailer = 'smtp';
195
+ $phpmailer->Host = 'smtp.pepipost.com';
196
+ $phpmailer->Port = get_option( 'pepipost_port' );
197
+ $phpmailer->SMTPSecure = get_option( 'pepipost_ssl' ) === 'none' ? '' : get_option( 'pepipost_ssl' );
198
+ $phpmailer->SMTPAuth = true;
199
+ $phpmailer->Username = get_option( 'pepipost_user' );
200
+ $phpmailer->Password = get_option( 'pepipost_pass' );
201
+ }
202
+ }
203
+
204
+ // You can add your own options here, see the phpmailer documentation for more info: http://phpmailer.sourceforge.net/docs/.
205
+ /** @noinspection PhpUnusedLocalVariableInspection It's passed by reference. */
206
+ $phpmailer = apply_filters( 'wp_mail_smtp_custom_options', $phpmailer );
207
}
208
+ endif;
209
210
+ if ( ! function_exists( 'wp_mail_smtp_options_page' ) ) :
211
+ /**
212
+ * This function outputs the plugin options page.
213
+ */
214
+ function wp_mail_smtp_options_page() {
215
216
+ global $phpmailer;
217
218
+ // Make sure the PHPMailer class has been instantiated
219
+ // (copied verbatim from wp-includes/pluggable.php)
220
+ // (Re)create it, if it's gone missing.
221
+ if ( ! is_object( $phpmailer ) || ! is_a( $phpmailer, 'PHPMailer' ) ) {
222
+ require_once ABSPATH . WPINC . '/class-phpmailer.php';
223
+ $phpmailer = new PHPMailer( true );
224
+ }
225
226
+ // Send a test mail if necessary.
227
+ if (
228
+ isset( $_POST['wpms_action'] ) &&
229
+ __( 'Send Test', 'wp-mail-smtp' ) === sanitize_text_field( $_POST['wpms_action'] ) &&
230
+ is_email( $_POST['to'] )
231
+ ) {
232
233
+ check_admin_referer( 'test-email' );
234
235
+ // Set up the mail variables.
236
+ $to = sanitize_text_field( $_POST['to'] );
237
+ /* translators: %s - email address where test mail will be sent to. */
238
+ $subject = 'WP Mail SMTP: ' . sprintf( __( 'Test mail to %s', 'wp-mail-smtp' ), $to );
239
+ $message = __( 'This is a test email generated by the WP Mail SMTP WordPress plugin.', 'wp-mail-smtp' );
240
241
+ // Set SMTPDebug level, default is 0 (no output).
242
+ $phpmailer->SMTPDebug = apply_filters( 'wp_mail_smtp_admin_test_email_smtp_debug', 0 );
243
244
+ // Start output buffering to grab smtp debugging output.
245
+ ob_start();
246
247
+ // Send the test mail.
248
+ $result = wp_mail( $to, $subject, $message );
249
250
+ // Grab the smtp debugging output.
251
+ $smtp_debug = ob_get_clean();
252
253
+ // Output the response.
254
+ ?>
255
+ <div id="message" class="updated notice is-dismissible"><p><strong><?php _e( 'Test Message Sent', 'wp-mail-smtp' ); ?></strong></p>
256
+ <p><?php _e( 'The result was:', 'wp-mail-smtp' ); ?></p>
257
+ <pre><?php var_dump( $result ); ?></pre>
258
259
+ <p><?php _e( 'The full debugging output is shown below:', 'wp-mail-smtp' ); ?></p>
260
+ <pre><?php print_r( $phpmailer ); ?></pre>
261
262
+ <p><?php _e( 'The SMTP debugging output is shown below:', 'wp-mail-smtp' ); ?></p>
263
+ <pre><?php echo $smtp_debug; ?></pre>
264
+ </div>
265
+ <?php
266
267
+ // Destroy $phpmailer so it doesn't cause issues later.
268
+ unset( $phpmailer );
269
+ }
270
271
+ ?>
272
+ <div class="wrap">
273
+ <h2>
274
+ <?php _e( 'WP Mail SMTP Settings', 'wp-mail-smtp' ); ?>
275
+ </h2>
276
+
277
+ <form method="post" action="<?php echo admin_url( 'options.php' ); ?>">
278
+ <?php wp_nonce_field( 'email-options' ); ?>
279
+
280
+ <table class="form-table">
281
+ <tr valign="top">
282
+ <th scope="row">
283
+ <label for="mail_from"><?php _e( 'From Email', 'wp-mail-smtp' ); ?></label>
284
+ </th>
285
+ <td>
286
+ <input name="mail_from" type="email" id="mail_from" value="<?php print( get_option( 'mail_from' ) ); ?>" size="40" class="regular-text"/>
287
+
288
+ <p class="description">
289
+ <?php
290
+ _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' );
291
+ if ( get_option( 'db_version' ) < 6124 ) {
292
+ print( '<br /><span style="color: red;">' );
293
+ _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' );
294
+ print( '</span>' );
295
+ }
296
+ ?>
297
+ </p>
298
+ </td>
299
+ </tr>
300
+ <tr valign="top">
301
+ <th scope="row">
302
+ <label for="mail_from_name"><?php _e( 'From Name', 'wp-mail-smtp' ); ?></label>
303
+ </th>
304
+ <td>
305
+ <input name="mail_from_name" type="text" id="mail_from_name" value="<?php print( get_option( 'mail_from_name' ) ); ?>" size="40" class="regular-text"/>
306
+
307
+ <p class="description">
308
+ <?php _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' ); ?>
309
+ </p>
310
+ </td>
311
+ </tr>
312
+ </table>
313
+
314
+ <table class="form-table">
315
+ <tr valign="top">
316
+ <th scope="row">
317
+ <?php _e( 'Mailer', 'wp-mail-smtp' ); ?>
318
+ </th>
319
+ <td>
320
+ <fieldset>
321
+ <legend class="screen-reader-text">
322
+ <span><?php _e( 'Mailer', 'wp-mail-smtp' ); ?></span>
323
+ </legend>
324
+
325
+ <p>
326
+ <input id="mailer_smtp" class="wpms_mailer" type="radio" name="mailer" value="smtp" <?php checked( 'smtp', get_option( 'mailer' ) ); ?> />
327
+ <label for="mailer_smtp"><?php _e( 'Send all WordPress emails via SMTP.', 'wp-mail-smtp' ); ?></label>
328
+ </p>
329
+ <p>
330
+ <input id="mailer_mail" class="wpms_mailer" type="radio" name="mailer" value="mail" <?php checked( 'mail', get_option( 'mailer' ) ); ?> />
331
+ <label for="mailer_mail"><?php _e( 'Use the PHP mail() function to send emails.', 'wp-mail-smtp' ); ?></label>
332
+ </p>
333
+
334
+ <?php if ( wp_mail_smtp_is_pepipost_active() ) : ?>
335
+ <p>
336
+ <input id="mailer_pepipost" class="wpms_mailer" type="radio" name="mailer" value="pepipost" <?php checked( 'pepipost', get_option( 'mailer' ) ); ?> />
337
+ <label for="mailer_pepipost"><?php _e( 'Use Pepipost SMTP to send emails.', 'wp-mail-smtp' ); ?></label>
338
+ </p>
339
+ <p class="description">
340
+ <?php
341
+ printf(
342
+ /* translators: %1$s - link start; %2$s - link end. */
343
+ __( 'Looking for high inbox delivery? Try Pepipost with easy setup and free emails. Learn more %1$shere%2$s.', 'wp-mail-smtp' ),
344
+ '<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">',
345
+ '</a>'
346
+ );
347
+ ?>
348
+ </p>
349
+ <?php endif; ?>
350
+ </fieldset>
351
+ </td>
352
+ </tr>
353
+ </table>
354
+
355
+ <table class="form-table">
356
+ <tr valign="top">
357
+ <th scope="row">
358
+ <?php _e( 'Return Path', 'wp-mail-smtp' ); ?>
359
+ </th>
360
+ <td>
361
+ <fieldset>
362
+ <legend class="screen-reader-text">
363
+ <span><?php _e( 'Return Path', 'wp-mail-smtp' ); ?></span>
364
+ </legend>
365
+
366
+ <label for="mail_set_return_path">
367
+ <input name="mail_set_return_path" type="checkbox" id="mail_set_return_path" value="true" <?php checked( 'true', get_option( 'mail_set_return_path' ) ); ?> />
368
+ <?php _e( 'Set the return-path to match the From Email', 'wp-mail-smtp' ); ?>
369
+ </label>
370
+
371
+ <p class="description">
372
+ <?php _e( 'Return Path indicates where non-delivery receipts - or bounce messages - are to be sent.', 'wp-mail-smtp' ); ?>
373
+ </p>
374
+ </fieldset>
375
+ </td>
376
+ </tr>
377
+ </table>
378
+
379
+ <p class="submit">
380
+ <input type="submit" name="submit" id="submit" class="button-primary" value="<?php _e( 'Save Changes', 'wp-mail-smtp' ); ?>"/>
381
+ </p>
382
+
383
+ <div id="wpms_section_smtp" class="wpms_section">
384
+ <h3>
385
+ <?php _e( 'SMTP Options', 'wp-mail-smtp' ); ?>
386
+ </h3>
387
+ <p><?php _e( 'These options only apply if you have chosen to send mail by SMTP above.', 'wp-mail-smtp' ); ?></p>
388
+
389
+ <table class="form-table">
390
+ <tr valign="top">
391
+ <th scope="row">
392
+ <label for="smtp_host"><?php _e( 'SMTP Host', 'wp-mail-smtp' ); ?></label>
393
+ </th>
394
+ <td>
395
+ <input name="smtp_host" type="text" id="smtp_host" value="<?php print( get_option( 'smtp_host' ) ); ?>" size="40" class="regular-text"/>
396
+ </td>
397
+ </tr>
398
+ <tr valign="top">
399
+ <th scope="row">
400
+ <label for="smtp_port"><?php _e( 'SMTP Port', 'wp-mail-smtp' ); ?></label>
401
+ </th>
402
+ <td>
403
+ <input name="smtp_port" type="text" id="smtp_port" value="<?php print( get_option( 'smtp_port' ) ); ?>" size="6" class="regular-text"/>
404
+ </td>
405
+ </tr>
406
+ <tr valign="top">
407
+ <th scope="row"><?php _e( 'Encryption', 'wp-mail-smtp' ); ?> </th>
408
+ <td>
409
+ <fieldset>
410
+ <legend class="screen-reader-text">
411
+ <span><?php _e( 'Encryption', 'wp-mail-smtp' ); ?></span>
412
+ </legend>
413
+
414
+ <input id="smtp_ssl_none" type="radio" name="smtp_ssl" value="none" <?php checked( 'none', get_option( 'smtp_ssl' ) ); ?> />
415
+ <label for="smtp_ssl_none">
416
+ <span><?php _e( 'No encryption.', 'wp-mail-smtp' ); ?></span>
417
+ </label><br/>
418
+
419
+ <input id="smtp_ssl_ssl" type="radio" name="smtp_ssl" value="ssl" <?php checked( 'ssl', get_option( 'smtp_ssl' ) ); ?> />
420
+ <label for="smtp_ssl_ssl">
421
+ <span><?php _e( 'Use SSL encryption.', 'wp-mail-smtp' ); ?></span>
422
+ </label><br/>
423
+
424
+ <input id="smtp_ssl_tls" type="radio" name="smtp_ssl" value="tls" <?php checked( 'tls', get_option( 'smtp_ssl' ) ); ?> />
425
+ <label for="smtp_ssl_tls">
426
+ <span><?php _e( 'Use TLS encryption.', 'wp-mail-smtp' ); ?></span>
427
+ </label>
428
+
429
+ <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>
430
+ </fieldset>
431
+ </td>
432
+ </tr>
433
+ <tr valign="top">
434
+ <th scope="row"><?php _e( 'Authentication', 'wp-mail-smtp' ); ?> </th>
435
+ <td>
436
+ <fieldset>
437
+ <legend class="screen-reader-text">
438
+ <span><?php _e( 'Authentication', 'wp-mail-smtp' ); ?></span>
439
+ </legend>
440
+
441
+ <input id="smtp_auth_false" type="radio" name="smtp_auth" value="false" <?php checked( 'false', get_option( 'smtp_auth' ) ); ?> />
442
+ <label for="smtp_auth_false">
443
+ <span><?php _e( 'No: Do not use SMTP authentication.', 'wp-mail-smtp' ); ?></span>
444
+ </label><br/>
445
+
446
+ <input id="smtp_auth_true" type="radio" name="smtp_auth" value="true" <?php checked( 'true', get_option( 'smtp_auth' ) ); ?> />
447
+ <label for="smtp_auth_true">
448
+ <span><?php _e( 'Yes: Use SMTP authentication.', 'wp-mail-smtp' ); ?></span>
449
+ </label><br/>
450
+
451
+ <p class="description">
452
+ <?php _e( 'If this is set to no, the values below are ignored.', 'wp-mail-smtp' ); ?>
453
+ </p>
454
+ </fieldset>
455
+ </td>
456
+ </tr>
457
+ <tr valign="top">
458
+ <th scope="row">
459
+ <label for="smtp_user"><?php _e( 'Username', 'wp-mail-smtp' ); ?></label>
460
+ </th>
461
+ <td>
462
+ <input name="smtp_user" type="text" id="smtp_user" value="<?php print( get_option( 'smtp_user' ) ); ?>" size="40" class="code"/>
463
+ </td>
464
+ </tr>
465
+ <tr valign="top">
466
+ <th scope="row">
467
+ <label for="smtp_pass"><?php _e( 'Password', 'wp-mail-smtp' ); ?></label>
468
+ </th>
469
+ <td>
470
+ <input name="smtp_pass" type="text" id="smtp_pass" value="<?php print( get_option( 'smtp_pass' ) ); ?>" size="40" class="code"/>
471
+
472
+ <p class="description">
473
+ <?php esc_html_e( 'This is in plain text because it must not be stored encrypted.', 'wp-mail-smtp' ); ?>
474
+ </p>
475
+ </td>
476
+ </tr>
477
+ </table>
478
+
479
+ <p class="submit">
480
+ <input type="submit" name="submit" id="submit" class="button-primary" value="<?php _e( 'Save Changes', 'wp-mail-smtp' ); ?>"/>
481
+ </p>
482
+ </div><!-- #wpms_section_smtp -->
483
+
484
+ <?php if ( wp_mail_smtp_is_pepipost_active() ) : ?>
485
+ <div id="wpms_section_pepipost" class="wpms_section">
486
+ <h3>
487
+ <?php _e( 'Pepipost SMTP Options', 'wp-mail-smtp' ); ?>
488
+ </h3>
489
+ <p>
490
+ <?php
491
+ printf(
492
+ /* translators: %s - Pepipost registration URL. */
493
+ __( 'You need to signup on %s to get the SMTP username/password.', 'wp-mail-smtp' ),
494
+ '<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>',
495
+ ''
496
+ );
497
+ ?>
498
+ </p>
499
+ <table class="form-table">
500
+ <tr valign="top">
501
+ <th scope="row">
502
+ <label for="pepipost_user"><?php _e( 'Username', 'wp-mail-smtp' ); ?></label>
503
+ </th>
504
+ <td>
505
+ <input name="pepipost_user" type="text" id="pepipost_user" value="<?php print( get_option( 'pepipost_user' ) ); ?>" size="40" class="code"/>
506
+ </td>
507
+ </tr>
508
+ <tr valign="top">
509
+ <th scope="row">
510
+ <label for="pepipost_pass"><?php _e( 'Password', 'wp-mail-smtp' ); ?></label>
511
+ </th>
512
+ <td>
513
+ <input name="pepipost_pass" type="text" id="pepipost_pass" value="<?php print( get_option( 'pepipost_pass' ) ); ?>" size="40" class="code"/>
514
+ </td>
515
+ </tr>
516
+ <tr valign="top">
517
+ <th scope="row">
518
+ <label for="pepipost_port"><?php _e( 'SMTP Port', 'wp-mail-smtp' ); ?></label>
519
+ </th>
520
+ <td>
521
+ <input name="pepipost_port" type="text" id="pepipost_port" value="<?php print( get_option( 'pepipost_port' ) ); ?>" size="6" class="regular-text"/>
522
+ </td>
523
+ </tr>
524
+ <tr valign="top">
525
+ <th scope="row">
526
+ <?php _e( 'Encryption', 'wp-mail-smtp' ); ?>
527
+ </th>
528
+ <td>
529
+ <fieldset>
530
+ <legend class="screen-reader-text">
531
+ <span>
532
+ <?php _e( 'Encryption', 'wp-mail-smtp' ); ?>
533
+ </span>
534
+ </legend>
535
+
536
+ <input id="pepipost_ssl_none" type="radio" name="pepipost_ssl" value="none" <?php checked( 'none', get_option( 'pepipost_ssl' ) ); ?> />
537
+ <label for="pepipost_ssl_none">
538
+ <span><?php _e( 'No encryption.', 'wp-mail-smtp' ); ?></span>
539
+ </label><br/>
540
+
541
+ <input id="pepipost_ssl_ssl" type="radio" name="pepipost_ssl" value="ssl" <?php checked( 'ssl', get_option( 'pepipost_ssl' ) ); ?> />
542
+ <label for="pepipost_ssl_ssl">
543
+ <span><?php _e( 'Use SSL encryption.', 'wp-mail-smtp' ); ?></span>
544
+ </label><br/>
545
+
546
+ <input id="pepipost_ssl_tls" type="radio" name="pepipost_ssl" value="tls" <?php checked( 'tls', get_option( 'pepipost_ssl' ) ); ?> />
547
+ <label for="pepipost_ssl_tls">
548
+ <span><?php _e( 'Use TLS encryption.', 'wp-mail-smtp' ); ?></span>
549
+ </label>
550
+ </fieldset>
551
+ </td>
552
+ </tr>
553
+ </table>
554
+
555
+ <p class="submit">
556
+ <input type="submit" name="submit" id="submit" class="button-primary" value="<?php _e( 'Save Changes', 'wp-mail-smtp' ); ?>"/>
557
+ </p>
558
+ </div><!-- #wpms_section_pepipost -->
559
+ <?php endif; ?>
560
+
561
+ <input type="hidden" name="action" value="update"/>
562
+ <input type="hidden" name="option_page" value="email">
563
+ </form>
564
+
565
+ <h3><?php _e( 'Send a Test Email', 'wp-mail-smtp' ); ?></h3>
566
+
567
+ <form method="POST" action="">
568
+ <?php wp_nonce_field( 'test-email' ); ?>
569
+
570
+ <table class="form-table">
571
+ <tr valign="top">
572
+ <th scope="row">
573
+ <label for="to"><?php _e( 'To', 'wp-mail-smtp' ); ?></label>
574
+ </th>
575
+ <td>
576
+ <input name="to" type="email" id="to" value="" size="40" class="code"/>
577
+ <p class="description"><?php _e( 'Type an email address here and then click Send Test to generate a test email.', 'wp-mail-smtp' ); ?></p>
578
+ </td>
579
+ </tr>
580
+ </table>
581
+
582
+ <p class="submit">
583
+ <input type="submit" name="wpms_action" id="wpms_action" class="button-primary" value="<?php _e( 'Send Test', 'wp-mail-smtp' ); ?>"/>
584
+ </p>
585
+ </form>
586
+
587
+ <script type="text/javascript">
588
+ /* globals jQuery */
589
+ var wpmsOnMailerChange = function ( mailer ) {
590
+ // Hide all the mailer forms.
591
+ jQuery( '.wpms_section' ).hide();
592
+ // Show the target mailer form.
593
+ jQuery( '#wpms_section_' + mailer ).show();
594
+ };
595
+ jQuery( document ).ready( function () {
596
+ // Call wpmsOnMailerChange() on startup with the current mailer.
597
+ wpmsOnMailerChange( jQuery( 'input.wpms_mailer:checked' ).val() );
598
+
599
+ // Watch the mailer for any changes
600
+ jQuery( 'input.wpms_mailer' ).on( 'change', function ( e ) {
601
+ // Call the wpmsOnMailerChange() handler, passing the value of the newly selected mailer.
602
+ wpmsOnMailerChange( jQuery( e.target ).val() );
603
+ } );
604
+ } );
605
+ </script>
606
+
607
+ </div>
608
+ <?php
609
+ } // End of wp_mail_smtp_options_page() function definition.
610
+ endif;
611
612
+ if ( ! function_exists( 'wp_mail_smtp_menus' ) ) :
613
+ /**
614
+ * This function adds the required page (only 1 at the moment).
615
+ */
616
+ function wp_mail_smtp_menus() {
617
618
+ if ( function_exists( 'add_submenu_page' ) ) {
619
+ add_options_page( __( 'WP Mail SMTP Settings', 'wp-mail-smtp' ), __( 'WP Mail SMTP', 'wp-mail-smtp' ), 'manage_options', __FILE__, 'wp_mail_smtp_options_page' );
620
+ }
621
+ } // End of wp_mail_smtp_menus() function definition.
622
+ endif;
623
624
+ if ( ! function_exists( 'wp_mail_smtp_mail_from' ) ) :
625
+ /**
626
+ * This function sets the from email value.
627
+ *
628
+ * @param string $orig
629
+ *
630
+ * @return string
631
+ */
632
+ function wp_mail_smtp_mail_from( $orig ) {
633
+ /*
634
+ * This is copied from pluggable.php lines 348-354 as at revision 10150
635
+ * http://trac.wordpress.org/browser/branches/2.7/wp-includes/pluggable.php#L348.
636
+ */
637
+
638
+ // In case of CLI we don't have SERVER_NAME, so use host name instead, may be not a domain name.
639
+ $server_name = ! empty( $_SERVER['SERVER_NAME'] ) ? $_SERVER['SERVER_NAME'] : wp_parse_url( get_home_url( get_current_blog_id() ), PHP_URL_HOST );
640
+
641
+ // Get the site domain and get rid of www.
642
+ $sitename = strtolower( $server_name );
643
+ if ( substr( $sitename, 0, 4 ) === 'www.' ) {
644
+ $sitename = substr( $sitename, 4 );
645
+ }
646
647
+ $default_from = 'wordpress@' . $sitename;
648
649
+ /*
650
+ * End of copied code.
651
+ */
652
653
+ // If the from email is not the default, return it unchanged.
654
+ if ( $orig !== $default_from ) {
655
+ return $orig;
656
+ }
657
658
+ if (
659
+ defined( 'WPMS_ON' ) && WPMS_ON &&
660
+ defined( 'WPMS_MAIL_FROM' )
661
+ ) {
662
+ $mail_from_email = WPMS_MAIL_FROM;
663
664
+ if ( ! empty( $mail_from_email ) ) {
665
+ return $mail_from_email;
666
+ }
667
+ }
668
669
+ if ( is_email( get_option( 'mail_from' ), false ) ) {
670
+ return get_option( 'mail_from' );
671
+ }
672
673
+ // If in doubt, return the original value.
674
+ return $orig;
675
+ } // End of wp_mail_smtp_mail_from() function definition.
676
+ endif;
677
678
+ if ( ! function_exists( 'wp_mail_smtp_mail_from_name' ) ) :
679
+ /**
680
+ * This function sets the from name value.
681
+ *
682
+ * @param string $orig
683
+ *
684
+ * @return string
685
+ */
686
+ function wp_mail_smtp_mail_from_name( $orig ) {
687
+
688
+ // Only filter if the from name is the default.
689
+ if ( 'WordPress' === $orig ) {
690
+ if (
691
+ defined( 'WPMS_ON' ) && WPMS_ON &&
692
+ defined( 'WPMS_MAIL_FROM_NAME' )
693
+ ) {
694
+ $mail_from_name = WPMS_MAIL_FROM_NAME;
695
+
696
+ if ( ! empty( $mail_from_name ) ) {
697
+ return $mail_from_name;
698
+ }
699
+ }
700
701
+ $from_name = get_option( 'mail_from_name' );
702
+ if ( ! empty( $from_name ) && is_string( $from_name ) ) {
703
+ return $from_name;
704
+ }
705
+ }
706
707
+ return $orig;
708
}
709
endif;
710
711
/**
712
+ * Add a link to Settings page of a plugin on Plugins page.
713
+ *
714
+ * @param array $links
715
+ * @param string $file
716
+ *
717
+ * @return mixed
718
*/
719
+ function wp_mail_plugin_action_links( $links, $file ) {
720
721
+ if ( plugin_basename( __FILE__ ) !== $file ) {
722
+ return $links;
723
}
724
725
+ $settings_link = '<a href="options-general.php?page=' . plugin_basename( __FILE__ ) . '">' . __( 'Settings', 'wp-mail-smtp' ) . '</a>';
726
+
727
+ array_unshift( $links, $settings_link );
728
729
+ return $links;
730
+ }
731
732
/**
733
+ * Awesome Motive Notifications.
734
+ *
735
+ * @since 0.11
736
*/
737
+ function wp_mail_smtp_am_notifications() {
738
739
+ if ( ! class_exists( 'WPMS_AM_Notification' ) ) {
740
+ require_once dirname( __FILE__ ) . '/class-wpms-am-notification.php';
741
}
742
743
+ new WPMS_AM_Notification( 'smtp', WPMS_PLUGIN_VER );
744
+ }
745
746
+ add_action( 'plugins_loaded', 'wp_mail_smtp_am_notifications' );
747
748
+ /**
749
+ * Check whether the site is using Pepipost or not.
750
+ *
751
+ * @since 0.11
752
+ *
753
+ * @return bool
754
+ */
755
+ function wp_mail_smtp_is_pepipost_active() {
756
+ return apply_filters( 'wp_mail_smtp_options_is_pepipost_active', 'pepipost' === get_option( 'mailer' ) );
757
+ }
758
759
/**
760
+ * Check the current PHP version and display a notice if on unsupported PHP.
761
+ *
762
+ * @since 0.11
763
*/
764
+ function wp_mail_smtp_check_php_version() {
765
766
+ // Display for PHP below 5.3.
767
+ if ( version_compare( PHP_VERSION, '5.3.0', '>=' ) ) {
768
+ return;
769
+ }
770
771
+ // Display for admins only.
772
+ if ( ! is_super_admin() ) {
773
+ return;
774
+ }
775
776
+ // Display on Dashboard page only.
777
+ if ( isset( $GLOBALS['pagenow'] ) && 'index.php' !== $GLOBALS['pagenow'] ) {
778
+ return;
779
+ }
780
781
+ echo '<div class="notice notice-error">' .
782
+ '<p>' .
783
+ sprintf(
784
+ /* translators: %1$s - WP Mail SMTP plugin name; %2$s - opening a link tag; %3$s - closing a link tag. */
785
+ __(
786
+ '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.',
787
+ 'wpforms'
788
+ ),
789
+ '<strong>WP Mail SMTP</strong>',
790
+ '<a href="https://wpforms.com/docs/supported-php-version/" target="_blank">',
791
+ '</a>'
792
+ ) .
793
+ '</p>' .
794
+ '</div>';
795
+ }
796