Easy WP SMTP - Version 1.2.4

Version Description

  • Improved the admin interface.
  • The test email details now gets saved after you use it. So you don't need to type it every single time you want to send a test email.
Download this release

Release Info

Developer wpecommerce
Plugin Icon 128x128 Easy WP SMTP
Version 1.2.4
Comparing to
See all releases

Code changes from version 1.2.3 to 1.2.4

Files changed (5) hide show
  1. css/style.css +13 -8
  2. easy-wp-smtp-admin-menu.php +264 -0
  3. easy-wp-smtp.php +194 -414
  4. js/script.js +13 -12
  5. readme.txt +5 -27
css/style.css CHANGED
@@ -1,14 +1,19 @@
1
  /**
2
  * Settings page
3
  */
4
- .swpsmtp_info {
5
- font-size: 10px;
6
- color: #888;
7
- }
8
- #swpsmtp_settings_form input[type='text'],
9
- input[type='password']{
10
- width: 250px;
11
  }
12
  textarea#swpsmtp_message{
13
- width: 250px;
 
 
 
 
 
 
 
 
 
 
14
  }
1
  /**
2
  * Settings page
3
  */
4
+ #swpsmtp_settings_form input[type='text'], input[type='password']{
5
+ width: 350px;
 
 
 
 
 
6
  }
7
  textarea#swpsmtp_message{
8
+ width: 350px;
9
+ }
10
+
11
+ .swpsmtp-yellow-box{
12
+ margin: 10px 0px;
13
+ padding: 10px;
14
+ background-color: #FFFFE0;
15
+ border-color: #E6DB55;
16
+ border-radius: 3px 3px 3px 3px;
17
+ border-style: solid;
18
+ border-width: 1px;
19
  }
easy-wp-smtp-admin-menu.php ADDED
@@ -0,0 +1,264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Add menu and submenu.
5
+ * @return void
6
+ */
7
+ function swpsmtp_admin_default_setup() {
8
+ //add_submenu_page( 'options-general.php', __( 'Easy WP SMTP', 'easy-wp-smtp' ), __( 'Easy WP SMTP', 'easy-wp-smtp' ), $capabilities, 'swpsmtp_settings', 'swpsmtp_settings' );
9
+ add_options_page(__('Easy WP SMTP', 'easy-wp-smtp'), __('Easy WP SMTP', 'easy-wp-smtp'), 'manage_options', 'swpsmtp_settings', 'swpsmtp_settings');
10
+ }
11
+
12
+ /**
13
+ * Renders the admin settings menu of the plugin.
14
+ * @return void
15
+ */
16
+ function swpsmtp_settings() {
17
+ echo '<div class="wrap" id="swpsmtp-mail">';
18
+ echo '<h2>' . __("Easy WP SMTP Settings", 'easy-wp-smtp') . '</h2>';
19
+ echo '<div id="poststuff"><div id="post-body">';
20
+
21
+ $display_add_options = $message = $error = $result = '';
22
+
23
+ $swpsmtp_options = get_option('swpsmtp_options');
24
+ $smtp_test_mail = get_option('smtp_test_mail');
25
+ if(empty($smtp_test_mail)){
26
+ $smtp_test_mail = array('swpsmtp_to' => '', 'swpsmtp_subject' => '', 'swpsmtp_message' => '', );
27
+ }
28
+
29
+ if (isset($_POST['swpsmtp_form_submit']) && check_admin_referer(plugin_basename(__FILE__), 'swpsmtp_nonce_name')) {
30
+ /* Update settings */
31
+ $swpsmtp_options['from_name_field'] = isset($_POST['swpsmtp_from_name']) ? sanitize_text_field(wp_unslash($_POST['swpsmtp_from_name'])) : '';
32
+ if (isset($_POST['swpsmtp_from_email'])) {
33
+ if (is_email($_POST['swpsmtp_from_email'])) {
34
+ $swpsmtp_options['from_email_field'] = sanitize_email($_POST['swpsmtp_from_email']);
35
+ } else {
36
+ $error .= " " . __("Please enter a valid email address in the 'FROM' field.", 'easy-wp-smtp');
37
+ }
38
+ }
39
+
40
+ $swpsmtp_options['smtp_settings']['host'] = sanitize_text_field($_POST['swpsmtp_smtp_host']);
41
+ $swpsmtp_options['smtp_settings']['type_encryption'] = ( isset($_POST['swpsmtp_smtp_type_encryption']) ) ? sanitize_text_field($_POST['swpsmtp_smtp_type_encryption']) : 'none';
42
+ $swpsmtp_options['smtp_settings']['autentication'] = ( isset($_POST['swpsmtp_smtp_autentication']) ) ? sanitize_text_field($_POST['swpsmtp_smtp_autentication']) : 'yes';
43
+ $swpsmtp_options['smtp_settings']['username'] = sanitize_text_field($_POST['swpsmtp_smtp_username']);
44
+ $smtp_password = trim($_POST['swpsmtp_smtp_password']);
45
+ $swpsmtp_options['smtp_settings']['password'] = base64_encode($smtp_password);
46
+
47
+ /* Check value from "SMTP port" option */
48
+ if (isset($_POST['swpsmtp_smtp_port'])) {
49
+ if (empty($_POST['swpsmtp_smtp_port']) || 1 > intval($_POST['swpsmtp_smtp_port']) || (!preg_match('/^\d+$/', $_POST['swpsmtp_smtp_port']) )) {
50
+ $swpsmtp_options['smtp_settings']['port'] = '25';
51
+ $error .= " " . __("Please enter a valid port in the 'SMTP Port' field.", 'easy-wp-smtp');
52
+ } else {
53
+ $swpsmtp_options['smtp_settings']['port'] = sanitize_text_field($_POST['swpsmtp_smtp_port']);
54
+ }
55
+ }
56
+
57
+ /* Update settings in the database */
58
+ if (empty($error)) {
59
+ update_option('swpsmtp_options', $swpsmtp_options);
60
+ $message .= __("Settings saved.", 'easy-wp-smtp');
61
+ } else {
62
+ $error .= " " . __("Settings are not saved.", 'easy-wp-smtp');
63
+ }
64
+ }
65
+
66
+ /* Send test letter */
67
+ if (isset($_POST['swpsmtp_test_submit']) && check_admin_referer(plugin_basename(__FILE__), 'swpsmtp_nonce_name')) {
68
+ if (isset($_POST['swpsmtp_to'])) {
69
+ if (is_email($_POST['swpsmtp_to'])) {
70
+ $swpsmtp_to = $_POST['swpsmtp_to'];
71
+ } else {
72
+ $error .= __("Please enter a valid email address in the recipient email field.", 'easy-wp-smtp');
73
+ }
74
+ }
75
+ $swpsmtp_subject = isset($_POST['swpsmtp_subject']) ? $_POST['swpsmtp_subject'] : '';
76
+ $swpsmtp_message = isset($_POST['swpsmtp_message']) ? $_POST['swpsmtp_message'] : '';
77
+
78
+ //Save the test mail details so it doesn't need to be filled in everytime.
79
+ $smtp_test_mail['swpsmtp_to'] = $swpsmtp_to;
80
+ $smtp_test_mail['swpsmtp_subject'] = $swpsmtp_subject;
81
+ $smtp_test_mail['swpsmtp_message'] = $swpsmtp_message;
82
+ update_option('smtp_test_mail', $smtp_test_mail);
83
+
84
+ if (!empty($swpsmtp_to)) {
85
+ $result = swpsmtp_test_mail($swpsmtp_to, $swpsmtp_subject, $swpsmtp_message);
86
+ }
87
+ }
88
+ ?>
89
+ <div class="swpsmtp-yellow-box">
90
+ Please visit the <a target="_blank" href="https://wp-ecommerce.net/easy-wordpress-smtp-send-emails-from-your-wordpress-site-using-a-smtp-server-2197">Easy WP SMTP</a> plugin's documentation page for usage instructions.
91
+ </div>
92
+
93
+ <div class="updated fade" <?php if (empty($message)) echo "style=\"display:none\""; ?>>
94
+ <p><strong><?php echo $message; ?></strong></p>
95
+ </div>
96
+ <div class="error" <?php if (empty($error)) echo "style=\"display:none\""; ?>>
97
+ <p><strong><?php echo $error; ?></strong></p>
98
+ </div>
99
+ <div id="swpsmtp-settings-notice" class="updated fade" style="display:none">
100
+ <p><strong><?php _e("Notice:", 'easy-wp-smtp'); ?></strong> <?php _e("The plugin's settings have been changed. In order to save them please don't forget to click the 'Save Changes' button.", 'easy-wp-smtp'); ?></p>
101
+ </div>
102
+
103
+ <div class="postbox">
104
+ <h3 class="hndle"><label for="title"><?php _e('SMTP Configuration Settings', 'easy-wp-smtp'); ?></label></h3>
105
+ <div class="inside">
106
+
107
+ <p>You can request your hosting provider for the SMTP details of your site. Use the SMTP details provided by your hosting provider to configure the following settings.</p>
108
+
109
+ <form id="swpsmtp_settings_form" method="post" action="">
110
+ <table class="form-table">
111
+ <tr valign="top">
112
+ <th scope="row"><?php _e("From Email Address", 'easy-wp-smtp'); ?></th>
113
+ <td>
114
+ <input type="text" name="swpsmtp_from_email" value="<?php echo esc_attr($swpsmtp_options['from_email_field']); ?>"/><br />
115
+ <p class="description"><?php _e("This email address will be used in the 'From' field.", 'easy-wp-smtp'); ?></p>
116
+ </td>
117
+ </tr>
118
+ <tr valign="top">
119
+ <th scope="row"><?php _e("From Name", 'easy-wp-smtp'); ?></th>
120
+ <td>
121
+ <input type="text" name="swpsmtp_from_name" value="<?php echo esc_attr($swpsmtp_options['from_name_field']); ?>"/><br />
122
+ <p class="description"><?php _e("This text will be used in the 'FROM' field", 'easy-wp-smtp'); ?></p>
123
+ </td>
124
+ </tr>
125
+ <tr class="ad_opt swpsmtp_smtp_options">
126
+ <th><?php _e('SMTP Host', 'easy-wp-smtp'); ?></th>
127
+ <td>
128
+ <input type='text' name='swpsmtp_smtp_host' value='<?php echo esc_attr($swpsmtp_options['smtp_settings']['host']); ?>' /><br />
129
+ <p class="description"><?php _e("Your mail server", 'easy-wp-smtp'); ?></p>
130
+ </td>
131
+ </tr>
132
+ <tr class="ad_opt swpsmtp_smtp_options">
133
+ <th><?php _e('Type of Encription', 'easy-wp-smtp'); ?></th>
134
+ <td>
135
+ <label for="swpsmtp_smtp_type_encryption_1"><input type="radio" id="swpsmtp_smtp_type_encryption_1" name="swpsmtp_smtp_type_encryption" value='none' <?php if ('none' == $swpsmtp_options['smtp_settings']['type_encryption']) echo 'checked="checked"'; ?> /> <?php _e('None', 'easy-wp-smtp'); ?></label>
136
+ <label for="swpsmtp_smtp_type_encryption_2"><input type="radio" id="swpsmtp_smtp_type_encryption_2" name="swpsmtp_smtp_type_encryption" value='ssl' <?php if ('ssl' == $swpsmtp_options['smtp_settings']['type_encryption']) echo 'checked="checked"'; ?> /> <?php _e('SSL', 'easy-wp-smtp'); ?></label>
137
+ <label for="swpsmtp_smtp_type_encryption_3"><input type="radio" id="swpsmtp_smtp_type_encryption_3" name="swpsmtp_smtp_type_encryption" value='tls' <?php if ('tls' == $swpsmtp_options['smtp_settings']['type_encryption']) echo 'checked="checked"'; ?> /> <?php _e('TLS', 'easy-wp-smtp'); ?></label><br />
138
+ <p class="description"><?php _e("For most servers SSL is the recommended option", 'easy-wp-smtp'); ?></p>
139
+ </td>
140
+ </tr>
141
+ <tr class="ad_opt swpsmtp_smtp_options">
142
+ <th><?php _e('SMTP Port', 'easy-wp-smtp'); ?></th>
143
+ <td>
144
+ <input type='text' name='swpsmtp_smtp_port' value='<?php echo esc_attr($swpsmtp_options['smtp_settings']['port']); ?>' /><br />
145
+ <p class="description"><?php _e("The port to your mail server", 'easy-wp-smtp'); ?></p>
146
+ </td>
147
+ </tr>
148
+ <tr class="ad_opt swpsmtp_smtp_options">
149
+ <th><?php _e('SMTP Authentication', 'easy-wp-smtp'); ?></th>
150
+ <td>
151
+ <label for="swpsmtp_smtp_autentication"><input type="radio" id="swpsmtp_smtp_autentication" name="swpsmtp_smtp_autentication" value='no' <?php if ('no' == $swpsmtp_options['smtp_settings']['autentication']) echo 'checked="checked"'; ?> /> <?php _e('No', 'easy-wp-smtp'); ?></label>
152
+ <label for="swpsmtp_smtp_autentication"><input type="radio" id="swpsmtp_smtp_autentication" name="swpsmtp_smtp_autentication" value='yes' <?php if ('yes' == $swpsmtp_options['smtp_settings']['autentication']) echo 'checked="checked"'; ?> /> <?php _e('Yes', 'easy-wp-smtp'); ?></label><br />
153
+ <p class="description"><?php _e("This options should always be checked 'Yes'", 'easy-wp-smtp'); ?></p>
154
+ </td>
155
+ </tr>
156
+ <tr class="ad_opt swpsmtp_smtp_options">
157
+ <th><?php _e('SMTP username', 'easy-wp-smtp'); ?></th>
158
+ <td>
159
+ <input type='text' name='swpsmtp_smtp_username' value='<?php echo esc_attr($swpsmtp_options['smtp_settings']['username']); ?>' /><br />
160
+ <p class="description"><?php _e("The username to login to your mail server", 'easy-wp-smtp'); ?></p>
161
+ </td>
162
+ </tr>
163
+ <tr class="ad_opt swpsmtp_smtp_options">
164
+ <th><?php _e('SMTP Password', 'easy-wp-smtp'); ?></th>
165
+ <td>
166
+ <input type='password' name='swpsmtp_smtp_password' value='<?php echo esc_attr(swpsmtp_get_password()); ?>' /><br />
167
+ <p class="description"><?php _e("The password to login to your mail server", 'easy-wp-smtp'); ?></p>
168
+ </td>
169
+ </tr>
170
+ </table>
171
+ <p class="submit">
172
+ <input type="submit" id="settings-form-submit" class="button-primary" value="<?php _e('Save Changes', 'easy-wp-smtp') ?>" />
173
+ <input type="hidden" name="swpsmtp_form_submit" value="submit" />
174
+ <?php wp_nonce_field(plugin_basename(__FILE__), 'swpsmtp_nonce_name'); ?>
175
+ </p>
176
+ </form>
177
+ </div><!-- end of inside -->
178
+ </div><!-- end of postbox -->
179
+
180
+ <div class="updated fade" <?php if (empty($result)) echo "style=\"display:none\""; ?>>
181
+ <p><strong><?php echo $result; ?></strong></p><!-- shows the result from the test email send function -->
182
+ </div>
183
+
184
+ <div class="postbox">
185
+ <h3 class="hndle"><label for="title"><?php _e('Testing And Debugging Settings', 'easy-wp-smtp'); ?></label></h3>
186
+ <div class="inside">
187
+
188
+ <p>You can use this section to send an email from your server using the above configured SMTP details to see if the email gets delivered.</p>
189
+
190
+ <form id="swpsmtp_settings_form" method="post" action="">
191
+ <table class="form-table">
192
+ <tr valign="top">
193
+ <th scope="row"><?php _e("To", 'easy-wp-smtp'); ?>:</th>
194
+ <td>
195
+ <input type="text" name="swpsmtp_to" value="<?php echo $smtp_test_mail['swpsmtp_to']; ?>" /><br />
196
+ <p class="description"><?php _e("Enter the recipient's email address", 'easy-wp-smtp'); ?></p>
197
+ </td>
198
+ </tr>
199
+ <tr valign="top">
200
+ <th scope="row"><?php _e("Subject", 'easy-wp-smtp'); ?>:</th>
201
+ <td>
202
+ <input type="text" name="swpsmtp_subject" value="<?php echo $smtp_test_mail['swpsmtp_subject']; ?>" /><br />
203
+ <p class="description"><?php _e("Enter a subject for your message", 'easy-wp-smtp'); ?></p>
204
+ </td>
205
+ </tr>
206
+ <tr valign="top">
207
+ <th scope="row"><?php _e("Message", 'easy-wp-smtp'); ?>:</th>
208
+ <td>
209
+ <textarea name="swpsmtp_message" id="swpsmtp_message" rows="5"><?php echo $smtp_test_mail['swpsmtp_message']; ?></textarea><br />
210
+ <p class="description"><?php _e("Write your email message", 'easy-wp-smtp'); ?></p>
211
+ </td>
212
+ </tr>
213
+ </table>
214
+ <p class="submit">
215
+ <input type="submit" id="settings-form-submit" class="button-primary" value="<?php _e('Send Test Email', 'easy-wp-smtp') ?>" />
216
+ <input type="hidden" name="swpsmtp_test_submit" value="submit" />
217
+ <?php wp_nonce_field(plugin_basename(__FILE__), 'swpsmtp_nonce_name'); ?>
218
+ </p>
219
+ </form>
220
+ </div><!-- end of inside -->
221
+ </div><!-- end of postbox -->
222
+
223
+ <?php
224
+ echo '</div></div>'; //<!-- end of #poststuff and #post-body -->
225
+ echo '</div>'; //<!-- end of .wrap #swpsmtp-mail .swpsmtp-mail -->
226
+ }
227
+
228
+ /**
229
+ * Plugin functions for init
230
+ * @return void
231
+ */
232
+ function swpsmtp_admin_init() {
233
+ /* Internationalization, first(!) */
234
+ load_plugin_textdomain('easy-wp-smtp', false, dirname(plugin_basename(__FILE__)) . '/languages/');
235
+
236
+ if (isset($_REQUEST['page']) && 'swpsmtp_settings' == $_REQUEST['page']) {
237
+ /* register plugin settings */
238
+ swpsmtp_register_settings();
239
+ }
240
+ }
241
+
242
+ /**
243
+ * Register settings function
244
+ * @return void
245
+ */
246
+ function swpsmtp_register_settings() {
247
+ $swpsmtp_options_default = array(
248
+ 'from_email_field' => '',
249
+ 'from_name_field' => '',
250
+ 'smtp_settings' => array(
251
+ 'host' => 'smtp.example.com',
252
+ 'type_encryption' => 'none',
253
+ 'port' => 25,
254
+ 'autentication' => 'yes',
255
+ 'username' => 'yourusername',
256
+ 'password' => 'yourpassword'
257
+ )
258
+ );
259
+
260
+ /* install the default plugin options */
261
+ if (!get_option('swpsmtp_options')) {
262
+ add_option('swpsmtp_options', $swpsmtp_options_default, '', 'yes');
263
+ }
264
+ }
easy-wp-smtp.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Easy WP SMTP
4
- Version: 1.2.3
5
  Plugin URI: https://wp-ecommerce.net/easy-wordpress-smtp-send-emails-from-your-wordpress-site-using-a-smtp-server-2197
6
  Author: wpecommerce
7
  Author URI: https://wp-ecommerce.net/
@@ -10,60 +10,9 @@ Text Domain: easy-wp-smtp
10
  Domain Path: /languages
11
  */
12
 
13
- /**
14
- * Add menu and submenu.
15
- * @return void
16
- */
17
-
18
- if ( ! function_exists( 'swpsmtp_admin_default_setup' ) ) {
19
- function swpsmtp_admin_default_setup() {
20
- //add_submenu_page( 'options-general.php', __( 'Easy WP SMTP', 'easy-wp-smtp' ), __( 'Easy WP SMTP', 'easy-wp-smtp' ), $capabilities, 'swpsmtp_settings', 'swpsmtp_settings' );
21
- add_options_page(__('Easy WP SMTP', 'easy-wp-smtp'), __('Easy WP SMTP', 'easy-wp-smtp'), 'manage_options', 'swpsmtp_settings', 'swpsmtp_settings');
22
- }
23
- }
24
-
25
- /**
26
- * Plugin functions for init
27
- * @return void
28
- */
29
- if ( ! function_exists ( 'swpsmtp_admin_init' ) ) {
30
- function swpsmtp_admin_init() {
31
- /* Internationalization, first(!) */
32
- load_plugin_textdomain( 'easy-wp-smtp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
33
-
34
- if ( isset( $_REQUEST['page'] ) && 'swpsmtp_settings' == $_REQUEST['page'] ) {
35
- /* register plugin settings */
36
- swpsmtp_register_settings();
37
- }
38
- }
39
- }
40
-
41
- /**
42
- * Register settings function
43
- * @return void
44
- */
45
- if ( ! function_exists( 'swpsmtp_register_settings' ) ) {
46
- function swpsmtp_register_settings() {
47
- $swpsmtp_options_default = array(
48
- 'from_email_field' => '',
49
- 'from_name_field' => '',
50
- 'smtp_settings' => array(
51
- 'host' => 'smtp.example.com',
52
- 'type_encryption' => 'none',
53
- 'port' => 25,
54
- 'autentication' => 'yes',
55
- 'username' => 'yourusername',
56
- 'password' => 'yourpassword'
57
- )
58
- );
59
-
60
- /* install the default plugin options */
61
- if ( ! get_option( 'swpsmtp_options' ) ){
62
- add_option( 'swpsmtp_options', $swpsmtp_options_default, '', 'yes' );
63
- }
64
- }
65
- }
66
 
 
67
 
68
  /**
69
  * Add action links on plugin page in to Plugin Name block
@@ -71,19 +20,21 @@ if ( ! function_exists( 'swpsmtp_register_settings' ) ) {
71
  * @param $file string relative path to pugin "easy-wp-smtp/easy-wp-smtp.php"
72
  * @return $links array() action links
73
  */
74
- if ( ! function_exists ( 'swpsmtp_plugin_action_links' ) ) {
75
- function swpsmtp_plugin_action_links( $links, $file ) {
76
- /* Static so we don't call plugin_basename on every plugin row. */
77
- static $this_plugin;
78
- if ( ! $this_plugin ) {
79
- $this_plugin = plugin_basename( __FILE__ );
80
- }
81
- if ( $file == $this_plugin ) {
82
- $settings_link = '<a href="options-general.php?page=swpsmtp_settings">' . __( 'Settings', 'easy-wp-smtp' ) . '</a>';
83
- array_unshift( $links, $settings_link );
84
- }
85
- return $links;
86
- }
 
 
87
  }
88
 
89
  /**
@@ -92,21 +43,25 @@ if ( ! function_exists ( 'swpsmtp_plugin_action_links' ) ) {
92
  * @param $file string relative path to pugin "easy-wp-smtp/easy-wp-smtp.php"
93
  * @return $links array() action links
94
  */
95
- if ( ! function_exists ( 'swpsmtp_register_plugin_links' ) ) {
96
- function swpsmtp_register_plugin_links( $links, $file ) {
97
- $base = plugin_basename( __FILE__ );
98
- if ( $file == $base ) {
99
- $links[] = '<a href="options-general.php?page=swpsmtp_settings">' . __( 'Settings', 'easy-wp-smtp' ) . '</a>';
100
- }
101
- return $links;
102
- }
 
 
103
  }
104
 
105
  //plugins_loaded action hook handler
106
- if( !function_exists ( 'swpsmtp_plugins_loaded_handler' ) ) {
 
107
  function swpsmtp_plugins_loaded_handler() {
108
- load_plugin_textdomain('easy-wp-smtp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/');
109
  }
 
110
  }
111
 
112
 
@@ -114,384 +69,209 @@ if( !function_exists ( 'swpsmtp_plugins_loaded_handler' ) ) {
114
  * Function to add plugin scripts
115
  * @return void
116
  */
117
- if ( ! function_exists ( 'swpsmtp_admin_head' ) ) {
118
- function swpsmtp_admin_head() {
119
- wp_enqueue_style( 'swpsmtp_stylesheet', plugins_url( 'css/style.css', __FILE__ ) );
120
-
121
- if ( isset( $_REQUEST['page'] ) && 'swpsmtp_settings' == $_REQUEST['page'] ) {
122
- wp_enqueue_script( 'swpsmtp_script', plugins_url( 'js/script.js', __FILE__ ), array( 'jquery' ) );
123
- }
124
- }
 
 
125
  }
126
 
127
  /**
128
  * Function to add smtp options in the phpmailer_init
129
  * @return void
130
  */
131
- if ( ! function_exists ( 'swpsmtp_init_smtp' ) ) {
132
- function swpsmtp_init_smtp( $phpmailer ) {
133
- //check if SMTP credentials have been configured.
134
- if(!swpsmtp_credentials_configured()){
135
- return;
136
- }
137
- $swpsmtp_options = get_option( 'swpsmtp_options' );
138
- /* Set the mailer type as per config above, this overrides the already called isMail method */
139
- $phpmailer->IsSMTP();
140
- $from_email = $swpsmtp_options['from_email_field'];
141
- $phpmailer->From = $from_email;
142
- $from_name = $swpsmtp_options['from_name_field'];
143
- $phpmailer->FromName = $from_name;
144
- $phpmailer->SetFrom($phpmailer->From, $phpmailer->FromName);
145
- /* Set the SMTPSecure value */
146
- if ( $swpsmtp_options['smtp_settings']['type_encryption'] !== 'none' ) {
147
- $phpmailer->SMTPSecure = $swpsmtp_options['smtp_settings']['type_encryption'];
148
- }
149
-
150
- /* Set the other options */
151
- $phpmailer->Host = $swpsmtp_options['smtp_settings']['host'];
152
- $phpmailer->Port = $swpsmtp_options['smtp_settings']['port'];
153
-
154
- /* If we're using smtp auth, set the username & password */
155
- if( 'yes' == $swpsmtp_options['smtp_settings']['autentication'] ){
156
- $phpmailer->SMTPAuth = true;
157
- $phpmailer->Username = $swpsmtp_options['smtp_settings']['username'];
158
- $phpmailer->Password = swpsmtp_get_password();
159
- }
160
- //PHPMailer 5.2.10 introduced this option. However, this might cause issues if the server is advertising TLS with an invalid certificate.
161
- $phpmailer->SMTPAutoTLS = false;
162
- }
163
- }
164
 
165
- /**
166
- * View function the settings to send messages.
167
- * @return void
168
- */
169
- if ( ! function_exists( 'swpsmtp_settings' ) ) {
170
- function swpsmtp_settings() {
171
- $display_add_options = $message = $error = $result = '';
172
-
173
- $swpsmtp_options = get_option( 'swpsmtp_options' );
174
-
175
- if ( isset( $_POST['swpsmtp_form_submit'] ) && check_admin_referer( plugin_basename( __FILE__ ), 'swpsmtp_nonce_name' ) ) {
176
- /* Update settings */
177
- $swpsmtp_options['from_name_field'] = isset( $_POST['swpsmtp_from_name'] ) ? sanitize_text_field(wp_unslash($_POST['swpsmtp_from_name'])) : '';
178
- if( isset( $_POST['swpsmtp_from_email'] ) ){
179
- if( is_email( $_POST['swpsmtp_from_email'] ) ){
180
- $swpsmtp_options['from_email_field'] = sanitize_email($_POST['swpsmtp_from_email']);
181
- }
182
- else{
183
- $error .= " " . __( "Please enter a valid email address in the 'FROM' field.", 'easy-wp-smtp' );
184
- }
185
- }
186
-
187
- $swpsmtp_options['smtp_settings']['host'] = sanitize_text_field($_POST['swpsmtp_smtp_host']);
188
- $swpsmtp_options['smtp_settings']['type_encryption'] = ( isset( $_POST['swpsmtp_smtp_type_encryption'] ) ) ? sanitize_text_field($_POST['swpsmtp_smtp_type_encryption']) : 'none' ;
189
- $swpsmtp_options['smtp_settings']['autentication'] = ( isset( $_POST['swpsmtp_smtp_autentication'] ) ) ? sanitize_text_field($_POST['swpsmtp_smtp_autentication']) : 'yes' ;
190
- $swpsmtp_options['smtp_settings']['username'] = sanitize_text_field($_POST['swpsmtp_smtp_username']);
191
- $smtp_password = trim($_POST['swpsmtp_smtp_password']);
192
- $swpsmtp_options['smtp_settings']['password'] = base64_encode($smtp_password);
193
-
194
- /* Check value from "SMTP port" option */
195
- if ( isset( $_POST['swpsmtp_smtp_port'] ) ) {
196
- if ( empty( $_POST['swpsmtp_smtp_port'] ) || 1 > intval( $_POST['swpsmtp_smtp_port'] ) || ( ! preg_match( '/^\d+$/', $_POST['swpsmtp_smtp_port'] ) ) ) {
197
- $swpsmtp_options['smtp_settings']['port'] = '25';
198
- $error .= " " . __( "Please enter a valid port in the 'SMTP Port' field.", 'easy-wp-smtp' );
199
- } else {
200
- $swpsmtp_options['smtp_settings']['port'] = sanitize_text_field($_POST['swpsmtp_smtp_port']);
201
- }
202
- }
203
-
204
- /* Update settings in the database */
205
- if ( empty( $error ) ) {
206
- update_option( 'swpsmtp_options', $swpsmtp_options );
207
- $message .= __( "Settings saved.", 'easy-wp-smtp' );
208
- }
209
- else{
210
- $error .= " " . __( "Settings are not saved.", 'easy-wp-smtp' );
211
- }
212
- }
213
-
214
- /* Send test letter */
215
- if ( isset( $_POST['swpsmtp_test_submit'] ) && check_admin_referer( plugin_basename( __FILE__ ), 'swpsmtp_nonce_name' ) ) {
216
- if( isset( $_POST['swpsmtp_to'] ) ){
217
- if( is_email( $_POST['swpsmtp_to'] ) ){
218
- $swpsmtp_to =$_POST['swpsmtp_to'];
219
- }
220
- else{
221
- $error .= " " . __( "Please enter a valid email address in the 'FROM' field.", 'easy-wp-smtp' );
222
- }
223
- }
224
- $swpsmtp_subject = isset( $_POST['swpsmtp_subject'] ) ? $_POST['swpsmtp_subject'] : '';
225
- $swpsmtp_message = isset( $_POST['swpsmtp_message'] ) ? $_POST['swpsmtp_message'] : '';
226
- if( ! empty( $swpsmtp_to ) )
227
- $result = swpsmtp_test_mail( $swpsmtp_to, $swpsmtp_subject, $swpsmtp_message );
228
- } ?>
229
- <div class="swpsmtp-mail wrap" id="swpsmtp-mail">
230
- <div id="icon-options-general" class="icon32 icon32-bws"></div>
231
- <h2><?php _e( "Easy WP SMTP Settings", 'easy-wp-smtp' ); ?></h2>
232
- <div class="update-nag">Please visit the <a target="_blank" href="https://wp-ecommerce.net/easy-wordpress-smtp-send-emails-from-your-wordpress-site-using-a-smtp-server-2197">Easy WP SMTP</a> documentation page for usage instructions.</div>
233
- <div class="updated fade" <?php if( empty( $message ) ) echo "style=\"display:none\""; ?>>
234
- <p><strong><?php echo $message; ?></strong></p>
235
- </div>
236
- <div class="error" <?php if ( empty( $error ) ) echo "style=\"display:none\""; ?>>
237
- <p><strong><?php echo $error; ?></strong></p>
238
- </div>
239
- <div id="swpsmtp-settings-notice" class="updated fade" style="display:none">
240
- <p><strong><?php _e( "Notice:", 'easy-wp-smtp' ); ?></strong> <?php _e( "The plugin's settings have been changed. In order to save them please don't forget to click the 'Save Changes' button.", 'easy-wp-smtp' ); ?></p>
241
- </div>
242
- <h3><?php _e( 'General Settings', 'easy-wp-smtp' ); ?></h3>
243
- <form id="swpsmtp_settings_form" method="post" action="">
244
- <table class="form-table">
245
- <tr valign="top">
246
- <th scope="row"><?php _e( "From Email Address", 'easy-wp-smtp' ); ?></th>
247
- <td>
248
- <input type="text" name="swpsmtp_from_email" value="<?php echo esc_attr( $swpsmtp_options['from_email_field'] ); ?>"/><br />
249
- <span class="swpsmtp_info"><?php _e( "This email address will be used in the 'From' field.", 'easy-wp-smtp' ); ?></span>
250
- </td>
251
- </tr>
252
- <tr valign="top">
253
- <th scope="row"><?php _e( "From Name", 'easy-wp-smtp' ); ?></th>
254
- <td>
255
- <input type="text" name="swpsmtp_from_name" value="<?php echo esc_attr($swpsmtp_options['from_name_field']); ?>"/><br />
256
- <span class="swpsmtp_info"><?php _e( "This text will be used in the 'FROM' field", 'easy-wp-smtp' ); ?></span>
257
- </td>
258
- </tr>
259
- <tr class="ad_opt swpsmtp_smtp_options">
260
- <th><?php _e( 'SMTP Host', 'easy-wp-smtp' ); ?></th>
261
- <td>
262
- <input type='text' name='swpsmtp_smtp_host' value='<?php echo esc_attr($swpsmtp_options['smtp_settings']['host']); ?>' /><br />
263
- <span class="swpsmtp_info"><?php _e( "Your mail server", 'easy-wp-smtp' ); ?></span>
264
- </td>
265
- </tr>
266
- <tr class="ad_opt swpsmtp_smtp_options">
267
- <th><?php _e( 'Type of Encription', 'easy-wp-smtp' ); ?></th>
268
- <td>
269
- <label for="swpsmtp_smtp_type_encryption_1"><input type="radio" id="swpsmtp_smtp_type_encryption_1" name="swpsmtp_smtp_type_encryption" value='none' <?php if( 'none' == $swpsmtp_options['smtp_settings']['type_encryption'] ) echo 'checked="checked"'; ?> /> <?php _e( 'None', 'easy-wp-smtp' ); ?></label>
270
- <label for="swpsmtp_smtp_type_encryption_2"><input type="radio" id="swpsmtp_smtp_type_encryption_2" name="swpsmtp_smtp_type_encryption" value='ssl' <?php if( 'ssl' == $swpsmtp_options['smtp_settings']['type_encryption'] ) echo 'checked="checked"'; ?> /> <?php _e( 'SSL', 'easy-wp-smtp' ); ?></label>
271
- <label for="swpsmtp_smtp_type_encryption_3"><input type="radio" id="swpsmtp_smtp_type_encryption_3" name="swpsmtp_smtp_type_encryption" value='tls' <?php if( 'tls' == $swpsmtp_options['smtp_settings']['type_encryption'] ) echo 'checked="checked"'; ?> /> <?php _e( 'TLS', 'easy-wp-smtp' ); ?></label><br />
272
- <span class="swpsmtp_info"><?php _e( "For most servers SSL is the recommended option", 'easy-wp-smtp' ); ?></span>
273
- </td>
274
- </tr>
275
- <tr class="ad_opt swpsmtp_smtp_options">
276
- <th><?php _e( 'SMTP Port', 'easy-wp-smtp' ); ?></th>
277
- <td>
278
- <input type='text' name='swpsmtp_smtp_port' value='<?php echo esc_attr($swpsmtp_options['smtp_settings']['port']); ?>' /><br />
279
- <span class="swpsmtp_info"><?php _e( "The port to your mail server", 'easy-wp-smtp' ); ?></span>
280
- </td>
281
- </tr>
282
- <tr class="ad_opt swpsmtp_smtp_options">
283
- <th><?php _e( 'SMTP Authentication', 'easy-wp-smtp' ); ?></th>
284
- <td>
285
- <label for="swpsmtp_smtp_autentication"><input type="radio" id="swpsmtp_smtp_autentication" name="swpsmtp_smtp_autentication" value='no' <?php if( 'no' == $swpsmtp_options['smtp_settings']['autentication'] ) echo 'checked="checked"'; ?> /> <?php _e( 'No', 'easy-wp-smtp' ); ?></label>
286
- <label for="swpsmtp_smtp_autentication"><input type="radio" id="swpsmtp_smtp_autentication" name="swpsmtp_smtp_autentication" value='yes' <?php if( 'yes' == $swpsmtp_options['smtp_settings']['autentication'] ) echo 'checked="checked"'; ?> /> <?php _e( 'Yes', 'easy-wp-smtp' ); ?></label><br />
287
- <span class="swpsmtp_info"><?php _e( "This options should always be checked 'Yes'", 'easy-wp-smtp' ); ?></span>
288
- </td>
289
- </tr>
290
- <tr class="ad_opt swpsmtp_smtp_options">
291
- <th><?php _e( 'SMTP username', 'easy-wp-smtp' ); ?></th>
292
- <td>
293
- <input type='text' name='swpsmtp_smtp_username' value='<?php echo esc_attr($swpsmtp_options['smtp_settings']['username']); ?>' /><br />
294
- <span class="swpsmtp_info"><?php _e( "The username to login to your mail server", 'easy-wp-smtp' ); ?></span>
295
- </td>
296
- </tr>
297
- <tr class="ad_opt swpsmtp_smtp_options">
298
- <th><?php _e( 'SMTP Password', 'easy-wp-smtp' ); ?></th>
299
- <td>
300
- <input type='password' name='swpsmtp_smtp_password' value='<?php echo esc_attr(swpsmtp_get_password()); ?>' /><br />
301
- <span class="swpsmtp_info"><?php _e( "The password to login to your mail server", 'easy-wp-smtp' ); ?></span>
302
- </td>
303
- </tr>
304
- </table>
305
- <p class="submit">
306
- <input type="submit" id="settings-form-submit" class="button-primary" value="<?php _e( 'Save Changes', 'easy-wp-smtp' ) ?>" />
307
- <input type="hidden" name="swpsmtp_form_submit" value="submit" />
308
- <?php wp_nonce_field( plugin_basename( __FILE__ ), 'swpsmtp_nonce_name' ); ?>
309
- </p>
310
- </form>
311
-
312
- <div class="updated fade" <?php if( empty( $result ) ) echo "style=\"display:none\""; ?>>
313
- <p><strong><?php echo $result; ?></strong></p>
314
- </div>
315
- <h3><?php _e( 'Testing And Debugging Settings', 'easy-wp-smtp' ); ?></h3>
316
- <form id="swpsmtp_settings_form" method="post" action="">
317
- <table class="form-table">
318
- <tr valign="top">
319
- <th scope="row"><?php _e( "To", 'easy-wp-smtp' ); ?>:</th>
320
- <td>
321
- <input type="text" name="swpsmtp_to" value=""/><br />
322
- <span class="swpsmtp_info"><?php _e( "Enter the email address to recipient", 'easy-wp-smtp' ); ?></span>
323
- </td>
324
- </tr>
325
- <tr valign="top">
326
- <th scope="row"><?php _e( "Subject", 'easy-wp-smtp' ); ?>:</th>
327
- <td>
328
- <input type="text" name="swpsmtp_subject" value=""/><br />
329
- <span class="swpsmtp_info"><?php _e( "Enter a subject for your message", 'easy-wp-smtp' ); ?></span>
330
- </td>
331
- </tr>
332
- <tr valign="top">
333
- <th scope="row"><?php _e( "Message", 'easy-wp-smtp' ); ?>:</th>
334
- <td>
335
- <textarea name="swpsmtp_message" id="swpsmtp_message" rows="5"></textarea><br />
336
- <span class="swpsmtp_info"><?php _e( "Write your message", 'easy-wp-smtp' ); ?></span>
337
- </td>
338
- </tr>
339
- </table>
340
- <p class="submit">
341
- <input type="submit" id="settings-form-submit" class="button-primary" value="<?php _e( 'Send Test Email', 'easy-wp-smtp' ) ?>" />
342
- <input type="hidden" name="swpsmtp_test_submit" value="submit" />
343
- <?php wp_nonce_field( plugin_basename( __FILE__ ), 'swpsmtp_nonce_name' ); ?>
344
- </p>
345
- </form>
346
- </div><!-- #swpsmtp-mail .swpsmtp-mail -->
347
- <?php }
348
  }
349
-
350
  /**
351
  * Function to test mail sending
352
  * @return text or errors
353
  */
354
- if ( ! function_exists( 'swpsmtp_test_mail' ) ) {
355
- function swpsmtp_test_mail( $to_email, $subject, $message ) {
356
- if(!swpsmtp_credentials_configured()){
357
- return;
358
- }
359
- $errors = '';
360
-
361
- $swpsmtp_options = get_option( 'swpsmtp_options' );
362
-
363
- require_once( ABSPATH . WPINC . '/class-phpmailer.php' );
364
- $mail = new PHPMailer();
365
-
366
- $charset = get_bloginfo( 'charset' );
367
- $mail->CharSet = $charset;
368
-
369
- $from_name = $swpsmtp_options['from_name_field'];
370
- $from_email = $swpsmtp_options['from_email_field'];
371
-
372
- $mail->IsSMTP();
373
-
374
- /* If using smtp auth, set the username & password */
375
- if( 'yes' == $swpsmtp_options['smtp_settings']['autentication'] ){
376
- $mail->SMTPAuth = true;
377
- $mail->Username = $swpsmtp_options['smtp_settings']['username'];
378
- $mail->Password = swpsmtp_get_password();
379
- }
380
-
381
- /* Set the SMTPSecure value, if set to none, leave this blank */
382
- if ( $swpsmtp_options['smtp_settings']['type_encryption'] !== 'none' ) {
383
- $mail->SMTPSecure = $swpsmtp_options['smtp_settings']['type_encryption'];
384
- }
385
-
386
- /* PHPMailer 5.2.10 introduced this option. However, this might cause issues if the server is advertising TLS with an invalid certificate. */
387
- $mail->SMTPAutoTLS = false;
388
-
389
- /* Set the other options */
390
- $mail->Host = $swpsmtp_options['smtp_settings']['host'];
391
- $mail->Port = $swpsmtp_options['smtp_settings']['port'];
392
- $mail->SetFrom( $from_email, $from_name );
393
- $mail->isHTML( true );
394
- $mail->Subject = $subject;
395
- $mail->MsgHTML( $message );
396
- $mail->AddAddress( $to_email );
397
- $mail->SMTPDebug = 0;
398
-
399
- /* Send mail and return result */
400
- if ( ! $mail->Send() )
401
- $errors = $mail->ErrorInfo;
402
-
403
- $mail->ClearAddresses();
404
- $mail->ClearAllRecipients();
405
-
406
- if ( ! empty( $errors ) ) {
407
- return $errors;
408
- }
409
- else{
410
- return 'Test mail was sent';
411
- }
412
- }
413
- }
414
 
415
- /**
416
- * Performed at uninstal.
417
- * @return void
418
- */
419
- if ( ! function_exists( 'swpsmtp_send_uninstall' ) ) {
420
- function swpsmtp_send_uninstall() {
421
- /* delete plugin options */
422
- delete_site_option( 'swpsmtp_options' );
423
- delete_option( 'swpsmtp_options' );
424
- }
425
  }
426
 
427
- if ( ! function_exists( 'swpsmtp_get_password' ) ) {
428
- function swpsmtp_get_password() {
429
- $swpsmtp_options = get_option( 'swpsmtp_options' );
430
- $temp_password = $swpsmtp_options['smtp_settings']['password'];
431
- $password = "";
432
- $decoded_pass = base64_decode($temp_password);
433
- /* no additional checks for servers that aren't configured with mbstring enabled */
434
- if ( ! function_exists( 'mb_detect_encoding' ) ){
435
- return $decoded_pass;
436
- }
437
- /* end of mbstring check */
438
- if (base64_encode($decoded_pass) === $temp_password) { //it might be encoded
439
- if(false === mb_detect_encoding($decoded_pass)){ //could not find character encoding.
440
- $password = $temp_password;
441
- }
442
- else{
443
- $password = base64_decode($temp_password);
444
- }
445
- }
446
- else{ //not encoded
447
  $password = $temp_password;
 
 
448
  }
449
- return $password;
450
- }
 
 
 
 
451
  }
452
 
453
- if ( ! function_exists( 'swpsmtp_admin_notice' ) ) {
454
- function swpsmtp_admin_notice() {
455
- if(!swpsmtp_credentials_configured()){
456
- $settings_url = admin_url().'options-general.php?page=swpsmtp_settings';
 
457
  ?>
458
  <div class="error">
459
- <p><?php printf(__('Please configure your SMTP credentials in the <a href="%s">settings menu</a> in order to send email using Easy WP SMTP plugin.', 'easy-wp-smtp'), esc_url($settings_url) ); ?></p>
460
  </div>
461
  <?php
462
  }
463
  }
 
464
  }
465
 
466
- if ( ! function_exists( 'swpsmtp_credentials_configured' ) ) {
 
467
  function swpsmtp_credentials_configured() {
468
- $swpsmtp_options = get_option( 'swpsmtp_options' );
469
  $credentials_configured = true;
470
- if(!isset($swpsmtp_options['from_email_field']) || empty($swpsmtp_options['from_email_field'])){
471
  $credentials_configured = false;
472
  }
473
- if(!isset($swpsmtp_options['from_name_field']) || empty($swpsmtp_options['from_name_field'])){
474
- $credentials_configured = false;;
 
475
  }
476
  return $credentials_configured;
477
  }
 
478
  }
479
 
 
 
 
 
 
 
 
 
 
 
 
 
 
480
 
481
  /**
482
  * Add all hooks
483
  */
 
 
 
484
 
485
- add_filter( 'plugin_action_links', 'swpsmtp_plugin_action_links', 10, 2 );
486
- add_action( 'plugins_loaded', 'swpsmtp_plugins_loaded_handler');
487
- add_filter( 'plugin_row_meta', 'swpsmtp_register_plugin_links', 10, 2 );
488
-
489
- add_action( 'phpmailer_init','swpsmtp_init_smtp');
490
 
491
- add_action( 'admin_menu', 'swpsmtp_admin_default_setup' );
492
 
493
- add_action( 'admin_init', 'swpsmtp_admin_init' );
494
- add_action( 'admin_enqueue_scripts', 'swpsmtp_admin_head' );
495
- add_action( 'admin_notices', 'swpsmtp_admin_notice' );
496
 
497
- register_uninstall_hook( plugin_basename( __FILE__ ), 'swpsmtp_send_uninstall' );
1
  <?php
2
  /*
3
  Plugin Name: Easy WP SMTP
4
+ Version: 1.2.4
5
  Plugin URI: https://wp-ecommerce.net/easy-wordpress-smtp-send-emails-from-your-wordpress-site-using-a-smtp-server-2197
6
  Author: wpecommerce
7
  Author URI: https://wp-ecommerce.net/
10
  Domain Path: /languages
11
  */
12
 
13
+ //Prefix/Slug - swpsmtp
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
+ include_once('easy-wp-smtp-admin-menu.php');
16
 
17
  /**
18
  * Add action links on plugin page in to Plugin Name block
20
  * @param $file string relative path to pugin "easy-wp-smtp/easy-wp-smtp.php"
21
  * @return $links array() action links
22
  */
23
+ if (!function_exists('swpsmtp_plugin_action_links')) {
24
+
25
+ function swpsmtp_plugin_action_links($links, $file) {
26
+ /* Static so we don't call plugin_basename on every plugin row. */
27
+ static $this_plugin;
28
+ if (!$this_plugin) {
29
+ $this_plugin = plugin_basename(__FILE__);
30
+ }
31
+ if ($file == $this_plugin) {
32
+ $settings_link = '<a href="options-general.php?page=swpsmtp_settings">' . __('Settings', 'easy-wp-smtp') . '</a>';
33
+ array_unshift($links, $settings_link);
34
+ }
35
+ return $links;
36
+ }
37
+
38
  }
39
 
40
  /**
43
  * @param $file string relative path to pugin "easy-wp-smtp/easy-wp-smtp.php"
44
  * @return $links array() action links
45
  */
46
+ if (!function_exists('swpsmtp_register_plugin_links')) {
47
+
48
+ function swpsmtp_register_plugin_links($links, $file) {
49
+ $base = plugin_basename(__FILE__);
50
+ if ($file == $base) {
51
+ $links[] = '<a href="options-general.php?page=swpsmtp_settings">' . __('Settings', 'easy-wp-smtp') . '</a>';
52
+ }
53
+ return $links;
54
+ }
55
+
56
  }
57
 
58
  //plugins_loaded action hook handler
59
+ if (!function_exists('swpsmtp_plugins_loaded_handler')) {
60
+
61
  function swpsmtp_plugins_loaded_handler() {
62
+ load_plugin_textdomain('easy-wp-smtp', false, dirname(plugin_basename(__FILE__)) . '/languages/');
63
  }
64
+
65
  }
66
 
67
 
69
  * Function to add plugin scripts
70
  * @return void
71
  */
72
+ if (!function_exists('swpsmtp_admin_head')) {
73
+
74
+ function swpsmtp_admin_head() {
75
+ wp_enqueue_style('swpsmtp_stylesheet', plugins_url('css/style.css', __FILE__));
76
+
77
+ if (isset($_REQUEST['page']) && 'swpsmtp_settings' == $_REQUEST['page']) {
78
+ wp_enqueue_script('swpsmtp_script', plugins_url('js/script.js', __FILE__), array('jquery'));
79
+ }
80
+ }
81
+
82
  }
83
 
84
  /**
85
  * Function to add smtp options in the phpmailer_init
86
  * @return void
87
  */
88
+ if (!function_exists('swpsmtp_init_smtp')) {
89
+
90
+ function swpsmtp_init_smtp($phpmailer) {
91
+ //check if SMTP credentials have been configured.
92
+ if (!swpsmtp_credentials_configured()) {
93
+ return;
94
+ }
95
+ $swpsmtp_options = get_option('swpsmtp_options');
96
+ /* Set the mailer type as per config above, this overrides the already called isMail method */
97
+ $phpmailer->IsSMTP();
98
+ $from_email = $swpsmtp_options['from_email_field'];
99
+ $phpmailer->From = $from_email;
100
+ $from_name = $swpsmtp_options['from_name_field'];
101
+ $phpmailer->FromName = $from_name;
102
+ $phpmailer->SetFrom($phpmailer->From, $phpmailer->FromName);
103
+ /* Set the SMTPSecure value */
104
+ if ($swpsmtp_options['smtp_settings']['type_encryption'] !== 'none') {
105
+ $phpmailer->SMTPSecure = $swpsmtp_options['smtp_settings']['type_encryption'];
106
+ }
107
+
108
+ /* Set the other options */
109
+ $phpmailer->Host = $swpsmtp_options['smtp_settings']['host'];
110
+ $phpmailer->Port = $swpsmtp_options['smtp_settings']['port'];
111
+
112
+ /* If we're using smtp auth, set the username & password */
113
+ if ('yes' == $swpsmtp_options['smtp_settings']['autentication']) {
114
+ $phpmailer->SMTPAuth = true;
115
+ $phpmailer->Username = $swpsmtp_options['smtp_settings']['username'];
116
+ $phpmailer->Password = swpsmtp_get_password();
117
+ }
118
+ //PHPMailer 5.2.10 introduced this option. However, this might cause issues if the server is advertising TLS with an invalid certificate.
119
+ $phpmailer->SMTPAutoTLS = false;
120
+ }
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  }
123
+
124
  /**
125
  * Function to test mail sending
126
  * @return text or errors
127
  */
128
+ if (!function_exists('swpsmtp_test_mail')) {
129
+
130
+ function swpsmtp_test_mail($to_email, $subject, $message) {
131
+ if (!swpsmtp_credentials_configured()) {
132
+ return;
133
+ }
134
+ $errors = '';
135
+
136
+ $swpsmtp_options = get_option('swpsmtp_options');
137
+
138
+ require_once( ABSPATH . WPINC . '/class-phpmailer.php' );
139
+ $mail = new PHPMailer();
140
+
141
+ $charset = get_bloginfo('charset');
142
+ $mail->CharSet = $charset;
143
+
144
+ $from_name = $swpsmtp_options['from_name_field'];
145
+ $from_email = $swpsmtp_options['from_email_field'];
146
+
147
+ $mail->IsSMTP();
148
+
149
+ /* If using smtp auth, set the username & password */
150
+ if ('yes' == $swpsmtp_options['smtp_settings']['autentication']) {
151
+ $mail->SMTPAuth = true;
152
+ $mail->Username = $swpsmtp_options['smtp_settings']['username'];
153
+ $mail->Password = swpsmtp_get_password();
154
+ }
155
+
156
+ /* Set the SMTPSecure value, if set to none, leave this blank */
157
+ if ($swpsmtp_options['smtp_settings']['type_encryption'] !== 'none') {
158
+ $mail->SMTPSecure = $swpsmtp_options['smtp_settings']['type_encryption'];
159
+ }
160
+
161
+ /* PHPMailer 5.2.10 introduced this option. However, this might cause issues if the server is advertising TLS with an invalid certificate. */
162
+ $mail->SMTPAutoTLS = false;
163
+
164
+ /* Set the other options */
165
+ $mail->Host = $swpsmtp_options['smtp_settings']['host'];
166
+ $mail->Port = $swpsmtp_options['smtp_settings']['port'];
167
+ $mail->SetFrom($from_email, $from_name);
168
+ $mail->isHTML(true);
169
+ $mail->Subject = $subject;
170
+ $mail->MsgHTML($message);
171
+ $mail->AddAddress($to_email);
172
+ $mail->SMTPDebug = 0;
173
+
174
+ /* Send mail and return result */
175
+ if (!$mail->Send())
176
+ $errors = $mail->ErrorInfo;
177
+
178
+ $mail->ClearAddresses();
179
+ $mail->ClearAllRecipients();
180
+
181
+ if (!empty($errors)) {
182
+ return $errors;
183
+ } else {
184
+ return 'Test mail was sent';
185
+ }
186
+ }
 
187
 
 
 
 
 
 
 
 
 
 
 
188
  }
189
 
190
+ if (!function_exists('swpsmtp_get_password')) {
191
+
192
+ function swpsmtp_get_password() {
193
+ $swpsmtp_options = get_option('swpsmtp_options');
194
+ $temp_password = $swpsmtp_options['smtp_settings']['password'];
195
+ $password = "";
196
+ $decoded_pass = base64_decode($temp_password);
197
+ /* no additional checks for servers that aren't configured with mbstring enabled */
198
+ if (!function_exists('mb_detect_encoding')) {
199
+ return $decoded_pass;
200
+ }
201
+ /* end of mbstring check */
202
+ if (base64_encode($decoded_pass) === $temp_password) { //it might be encoded
203
+ if (false === mb_detect_encoding($decoded_pass)) { //could not find character encoding.
 
 
 
 
 
 
204
  $password = $temp_password;
205
+ } else {
206
+ $password = base64_decode($temp_password);
207
  }
208
+ } else { //not encoded
209
+ $password = $temp_password;
210
+ }
211
+ return $password;
212
+ }
213
+
214
  }
215
 
216
+ if (!function_exists('swpsmtp_admin_notice')) {
217
+
218
+ function swpsmtp_admin_notice() {
219
+ if (!swpsmtp_credentials_configured()) {
220
+ $settings_url = admin_url() . 'options-general.php?page=swpsmtp_settings';
221
  ?>
222
  <div class="error">
223
+ <p><?php printf(__('Please configure your SMTP credentials in the <a href="%s">settings menu</a> in order to send email using Easy WP SMTP plugin.', 'easy-wp-smtp'), esc_url($settings_url)); ?></p>
224
  </div>
225
  <?php
226
  }
227
  }
228
+
229
  }
230
 
231
+ if (!function_exists('swpsmtp_credentials_configured')) {
232
+
233
  function swpsmtp_credentials_configured() {
234
+ $swpsmtp_options = get_option('swpsmtp_options');
235
  $credentials_configured = true;
236
+ if (!isset($swpsmtp_options['from_email_field']) || empty($swpsmtp_options['from_email_field'])) {
237
  $credentials_configured = false;
238
  }
239
+ if (!isset($swpsmtp_options['from_name_field']) || empty($swpsmtp_options['from_name_field'])) {
240
+ $credentials_configured = false;
241
+ ;
242
  }
243
  return $credentials_configured;
244
  }
245
+
246
  }
247
 
248
+ /**
249
+ * Performed at uninstal.
250
+ * @return void
251
+ */
252
+ if (!function_exists('swpsmtp_send_uninstall')) {
253
+
254
+ function swpsmtp_send_uninstall() {
255
+ /* delete plugin options */
256
+ delete_site_option('swpsmtp_options');
257
+ delete_option('swpsmtp_options');
258
+ }
259
+
260
+ }
261
 
262
  /**
263
  * Add all hooks
264
  */
265
+ add_filter('plugin_action_links', 'swpsmtp_plugin_action_links', 10, 2);
266
+ add_action('plugins_loaded', 'swpsmtp_plugins_loaded_handler');
267
+ add_filter('plugin_row_meta', 'swpsmtp_register_plugin_links', 10, 2);
268
 
269
+ add_action('phpmailer_init', 'swpsmtp_init_smtp');
 
 
 
 
270
 
271
+ add_action('admin_menu', 'swpsmtp_admin_default_setup');
272
 
273
+ add_action('admin_init', 'swpsmtp_admin_init');
274
+ add_action('admin_enqueue_scripts', 'swpsmtp_admin_head');
275
+ add_action('admin_notices', 'swpsmtp_admin_notice');
276
 
277
+ register_uninstall_hook(plugin_basename(__FILE__), 'swpsmtp_send_uninstall');
js/script.js CHANGED
@@ -1,13 +1,14 @@
1
- (function( $ ){
2
- $( document ).ready( function() {
3
- /*
4
- *add notice about changing in the settings page
5
- */
6
- $( '#swpsmtp-mail input' ).bind( "change select", function() {
7
- if ( $( this ).attr( 'type' ) != 'submit' ) {
8
- $( '.updated.fade' ).css( 'display', 'none' );
9
- $( '#swpsmtp-settings-notice' ).css( 'display', 'block' );
10
- };
11
- });
12
- });
 
13
  })(jQuery);
1
+ (function($) {
2
+ $(document).ready(function() {
3
+ /*
4
+ *add notice about changing in the settings page
5
+ */
6
+ $('#swpsmtp-mail input').bind("change select", function() {
7
+ if ($(this).attr('type') != 'submit') {
8
+ $('.updated.fade').css('display', 'none');
9
+ $('#swpsmtp-settings-notice').css('display', 'block');
10
+ }
11
+ ;
12
+ });
13
+ });
14
  })(jQuery);
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://wp-ecommerce.net/easy-wordpress-smtp-send-emails-from-your-
4
  Tags: mail, wordpress smtp, phpmailer, smtp, wp_mail, email, gmail, outgoing mail, privacy, security, sendmail, ssl, tls, wp-phpmailer, mail smtp, wp smtp
5
  Requires at least: 4.3
6
  Tested up to: 4.7
7
- Stable tag: 1.2.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -75,108 +75,86 @@ Inspired by [WP Mail SMTP](http://wordpress.org/plugins/wp-mail-smtp/) plugin
75
 
76
  == Changelog ==
77
 
78
- = 1.2.3 =
 
 
79
 
 
80
  * Easy WP SMTP is now compatible with WordPress 4.5.
81
 
82
  = 1.2.2 =
83
-
84
  * Easy WP SMTP is now compatible with WordPress 4.4.
85
 
86
  = 1.2.1 =
87
-
88
  * Set SMTPAutoTLS to false by default as it might cause issues if the server is advertising TLS with an invalid certificate.
89
  * Display an error message near the top of admin pages if SMTP credentials are not configured.
90
 
91
  = 1.2.0 =
92
-
93
  * Set email charset to utf-8 for test email functionality.
94
  * Run additional checks on the password only if mbstring is enabled on the server. This should fix the issue with password input field not appearing on some servers.
95
 
96
  = 1.1.9 =
97
-
98
  * Easy SMTP is now compatible with WordPress 4.3
99
 
100
  = 1.1.8 =
101
-
102
  * Easy SMTP now removes slashes from the "From Name" field.
103
 
104
  = 1.1.7 =
105
-
106
  * Made some improvements to the encoding option.
107
 
108
  = 1.1.7 =
109
-
110
  * Made some improvements to the encoding option.
111
 
112
  = 1.1.6 =
113
-
114
  * Fixed some character encoding issues of test email functionality
115
  * Plugin will now force the from name and email address saved in the settings (just like version 1.1.1)
116
 
117
  = 1.1.5 =
118
-
119
  * Fixed a typo in the plugin settings
120
  * SMTP Password is now encoded before saving it to the wp_options table
121
 
122
  = 1.1.4 =
123
-
124
  * Plugin will now also override the default from name and email (WordPress)
125
 
126
  = 1.1.3 =
127
-
128
  * Removed "ReplyTo" attribute since it was causing compatibility issues with some form plugins
129
 
130
  = 1.1.2 =
131
-
132
  * "ReplyTo" attribute will now be set when sending an email
133
  * The plugin will only override "From Email Address" and "Name" if they are not present
134
 
135
  = 1.1.1 =
136
-
137
  * Fixed an issue where the plugin CSS was affecting other input fields on the admin side.
138
 
139
  = 1.1.0 =
140
-
141
  * "The settings have been changed" notice will only be displayed if a input field is changed
142
 
143
  = 1.0.9 =
144
-
145
  * Fixed some bugs in the SMTP configuration and mail functionality
146
 
147
  = 1.0.8 =
148
-
149
  * Plugin now works with WordPress 3.9
150
 
151
  = 1.0.7 =
152
-
153
  * Plugin now works with WordPress 3.8
154
 
155
  = 1.0.6 =
156
-
157
  * Plugin is now compatible with WordPress 3.7
158
 
159
  = 1.0.5 =
160
-
161
  * "Reply-To" text will no longer be added to the email header
162
  * From Name field can now contain quotes. It will no longer be converted to '\'
163
 
164
  = 1.0.4 =
165
-
166
  * Plugin is now compatible with WordPress 3.6
167
 
168
  = 1.0.3 =
169
-
170
  * Added a new option to the settings which allows a user to enable/disable SMTP debug
171
-
172
  = 1.0.2 =
173
-
174
  * Fixed a bug where the debug output was being displayed on the front end
175
 
176
  = 1.0.1 =
177
-
178
  * First commit of the plugin
179
 
180
  == Upgrade Notice ==
181
-
182
  There were some major changes in version 1.0.8. So you will need to reconfigure the SMTP options after the upgrade.
4
  Tags: mail, wordpress smtp, phpmailer, smtp, wp_mail, email, gmail, outgoing mail, privacy, security, sendmail, ssl, tls, wp-phpmailer, mail smtp, wp smtp
5
  Requires at least: 4.3
6
  Tested up to: 4.7
7
+ Stable tag: 1.2.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
75
 
76
  == Changelog ==
77
 
78
+ = 1.2.4 =
79
+ * Improved the admin interface.
80
+ * The test email details now gets saved after you use it. So you don't need to type it every single time you want to send a test email.
81
 
82
+ = 1.2.3 =
83
  * Easy WP SMTP is now compatible with WordPress 4.5.
84
 
85
  = 1.2.2 =
 
86
  * Easy WP SMTP is now compatible with WordPress 4.4.
87
 
88
  = 1.2.1 =
 
89
  * Set SMTPAutoTLS to false by default as it might cause issues if the server is advertising TLS with an invalid certificate.
90
  * Display an error message near the top of admin pages if SMTP credentials are not configured.
91
 
92
  = 1.2.0 =
 
93
  * Set email charset to utf-8 for test email functionality.
94
  * Run additional checks on the password only if mbstring is enabled on the server. This should fix the issue with password input field not appearing on some servers.
95
 
96
  = 1.1.9 =
 
97
  * Easy SMTP is now compatible with WordPress 4.3
98
 
99
  = 1.1.8 =
 
100
  * Easy SMTP now removes slashes from the "From Name" field.
101
 
102
  = 1.1.7 =
 
103
  * Made some improvements to the encoding option.
104
 
105
  = 1.1.7 =
 
106
  * Made some improvements to the encoding option.
107
 
108
  = 1.1.6 =
 
109
  * Fixed some character encoding issues of test email functionality
110
  * Plugin will now force the from name and email address saved in the settings (just like version 1.1.1)
111
 
112
  = 1.1.5 =
 
113
  * Fixed a typo in the plugin settings
114
  * SMTP Password is now encoded before saving it to the wp_options table
115
 
116
  = 1.1.4 =
 
117
  * Plugin will now also override the default from name and email (WordPress)
118
 
119
  = 1.1.3 =
 
120
  * Removed "ReplyTo" attribute since it was causing compatibility issues with some form plugins
121
 
122
  = 1.1.2 =
 
123
  * "ReplyTo" attribute will now be set when sending an email
124
  * The plugin will only override "From Email Address" and "Name" if they are not present
125
 
126
  = 1.1.1 =
 
127
  * Fixed an issue where the plugin CSS was affecting other input fields on the admin side.
128
 
129
  = 1.1.0 =
 
130
  * "The settings have been changed" notice will only be displayed if a input field is changed
131
 
132
  = 1.0.9 =
 
133
  * Fixed some bugs in the SMTP configuration and mail functionality
134
 
135
  = 1.0.8 =
 
136
  * Plugin now works with WordPress 3.9
137
 
138
  = 1.0.7 =
 
139
  * Plugin now works with WordPress 3.8
140
 
141
  = 1.0.6 =
 
142
  * Plugin is now compatible with WordPress 3.7
143
 
144
  = 1.0.5 =
 
145
  * "Reply-To" text will no longer be added to the email header
146
  * From Name field can now contain quotes. It will no longer be converted to '\'
147
 
148
  = 1.0.4 =
 
149
  * Plugin is now compatible with WordPress 3.6
150
 
151
  = 1.0.3 =
 
152
  * Added a new option to the settings which allows a user to enable/disable SMTP debug
 
153
  = 1.0.2 =
 
154
  * Fixed a bug where the debug output was being displayed on the front end
155
 
156
  = 1.0.1 =
 
157
  * First commit of the plugin
158
 
159
  == Upgrade Notice ==
 
160
  There were some major changes in version 1.0.8. So you will need to reconfigure the SMTP options after the upgrade.