Configure SMTP - Version 2.7

Version Description

  • Fix to prevent HTML entities from appearing in the From name value in outgoing e-mails
  • Added full support for localization
  • Added .pot file
  • Noted that overriding the From e-mail value may not take effect depending on mail server and settings, particular if SMTPAuth is used (i.e. GMail)
  • Changed invocation of plugin's install function to action hooked in constructor rather than in global space
  • Update object's option buffer after saving changed submitted by user
  • Miscellaneous tweaks to update plugin to my current plugin conventions
  • Noted compatibility with WP2.9+
  • Dropped compatibility with versions of WP older than 2.8
  • Updated readme.txt
  • Updated copyright date
Download this release

Release Info

Developer coffee2code
Plugin Icon wp plugin Configure SMTP
Version 2.7
Comparing to
See all releases

Code changes from version 2.5 to 2.7

Files changed (3) hide show
  1. configure-smtp.php +133 -142
  2. configure-smtp.pot +218 -0
  3. readme.txt +56 -10
configure-smtp.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
  /*
3
  Plugin Name: Configure SMTP
4
- Version: 2.5
5
  Plugin URI: http://coffee2code.com/wp-plugins/configure-smtp
6
  Author: Scott Reilly
7
  Author URI: http://coffee2code.com
8
- Description: Configure SMTP mailing in WordPress, including support for sending e-mail via GMail.
9
 
10
  This plugin is the renamed, rewritten, and updated version of the wpPHPMailer plugin.
11
 
@@ -29,7 +29,7 @@ email of the 'From:' field for all outgoing e-mails.
29
  A simple test button is also available that allows you to send a test e-mail to yourself to check if sending
30
  e-mail has been properly configured for your blog.
31
 
32
- Compatible with WordPress 2.2+, 2.3+, 2.5+, 2.6+, 2.7+.
33
 
34
  =>> Read the accompanying readme.txt file for more information. Also, visit the plugin's homepage
35
  =>> for more information and the latest updates
@@ -37,7 +37,7 @@ Compatible with WordPress 2.2+, 2.3+, 2.5+, 2.6+, 2.7+.
37
  Installation:
38
 
39
  1. Download the file http://coffee2code.com/wp-plugins/configure-smtp.zip and unzip it into your
40
- /wp-content/plugins/ directory.
41
  2. Activate the plugin through the 'Plugins' admin menu in WordPress.
42
  3. Click the plugin's 'Settings' link next to its 'Deactivate' link (still on the Plugins page), or click on the
43
  Settings -> SMTP link, to go to the plugin's admin settings page. Optionally customize the settings (to configure it
@@ -47,7 +47,7 @@ if the defaults aren't valid for your situation).
47
  */
48
 
49
  /*
50
- Copyright (c) 2004-2009 by Scott Reilly (aka coffee2code)
51
 
52
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
53
  files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
@@ -65,50 +65,14 @@ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
65
  if ( !class_exists('ConfigureSMTP') ) :
66
 
67
  class ConfigureSMTP {
68
- var $plugin_name = '';
69
  var $admin_options_name = 'c2c_configure_smtp';
70
  var $nonce_field = 'update-configure_smtp';
 
71
  var $show_admin = true; // Change this to false if you don't want the plugin's admin page shown.
72
- var $config = array(
73
- // input can be 'checkbox', 'short_text', 'text', 'textarea', 'inline_textarea', 'select', 'hidden', 'password', or 'none'
74
- // an input type of 'select' must then have an 'options' value (an array) specified
75
- // datatype can be 'array' or 'hash'
76
- // can also specify input_attributes
77
- 'use_gmail' => array('input' => 'checkbox', 'default' => false,
78
- 'label' => 'Send e-mail via GMail?',
79
- 'help' => 'Clicking this will override many of the settings defined below. You will need to input your GMail username and password below.',
80
- 'input_attributes' => 'onclick="return configure_gmail();"'),
81
- 'host' => array('input' => 'text', 'default' => 'localhost',
82
- 'label' => 'SMTP host',
83
- 'help' => 'If "localhost" doesn\'t work for you, check with your host for the SMTP hostname.'),
84
- 'port' => array('input' => 'short_text', 'default' => 25,
85
- 'label' => 'SMTP port',
86
- 'help' => "This is generally 25."),
87
- 'smtp_secure' => array('input' => 'select', 'default' => 'None',
88
- 'label' => 'Secure connection prefix',
89
- 'options' => array('', 'ssl', 'tls'),
90
- 'help' => 'Sets connection prefix for secure connections (prefix method must be supported by your PHP install and your SMTP host)'),
91
- 'smtp_auth' => array('input' => 'checkbox', 'default' => false,
92
- 'label' => 'Use SMTPAuth?',
93
- 'help' => 'If checked, you must provide the SMTP username and password below'),
94
- 'smtp_user' => array('input' => 'text', 'default' => '',
95
- 'label' => 'SMTP username',
96
- 'help' => ''),
97
- 'smtp_pass' => array('input' => 'password', 'default' => '',
98
- 'label' => 'SMTP password',
99
- 'help' => ''),
100
- 'wordwrap' => array('input' => 'short_text', 'default' => '',
101
- 'label' => 'Wordwrap length',
102
- 'help' => 'Sets word wrapping on the body of the message to a given number of characters.'),
103
- 'from_email' => array('input' => 'text', 'default' => '',
104
- 'label' => 'Sender e-mail',
105
- 'help' => 'Sets the From email address for all outgoing messages. Leave blank to use the
106
- WordPress default. This value will be used even if you don\'t enable SMTP.'),
107
- 'from_name' => array('input' => 'text', 'default' => '',
108
- 'label' => 'Sender name',
109
- 'help' => 'Sets the From name for all outgoing messages. Leave blank to use the WordPress default.
110
- This value will be used even if you don\'t enable SMTP.')
111
- );
112
  var $gmail_config = array(
113
  'host' => 'smtp.gmail.com',
114
  'port' => '465',
@@ -118,8 +82,52 @@ class ConfigureSMTP {
118
  var $options = array(); // Don't use this directly
119
 
120
  function ConfigureSMTP() {
121
- $this->plugin_name = __('Configure SMTP');
122
- add_action('admin_head', array(&$this, 'add_js'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  add_action('admin_menu', array(&$this, 'admin_menu'));
124
  add_action('phpmailer_init', array(&$this, 'phpmailer_init'));
125
  add_action('wp_mail_from', array(&$this, 'wp_mail_from'));
@@ -132,6 +140,7 @@ class ConfigureSMTP {
132
  }
133
 
134
  function add_js() {
 
135
  echo <<<JS
136
  <script type="text/javascript">
137
  function configure_gmail() {
@@ -143,7 +152,7 @@ class ConfigureSMTP {
143
  if (!jQuery('#smtp_user').val().match(/.+@gmail.com$/) ) {
144
  jQuery('#smtp_user').val('USERNAME@gmail.com').focus().get(0).setSelectionRange(0,8);
145
  }
146
- alert('Be sure to specify your GMail email address (with the @gmail.com) as the SMTP username, and your GMail password as the SMTP password.');
147
  return true;
148
  }
149
  }
@@ -153,77 +162,66 @@ JS;
153
  }
154
 
155
  function admin_menu() {
156
- static $plugin_basename;
157
- if ( $this->show_admin ) {
158
- global $wp_version;
159
- if ( current_user_can('edit_posts') ) {
160
- $plugin_basename = plugin_basename(__FILE__);
161
- if ( version_compare( $wp_version, '2.6.999', '>' ) )
162
- add_filter( 'plugin_action_links_' . $plugin_basename, array(&$this, 'plugin_action_links') );
163
- add_options_page($this->plugin_name, 'SMTP', 9, $plugin_basename, array(&$this, 'options_page'));
164
- }
165
  }
166
  }
167
 
168
- function plugin_action_links($action_links) {
169
- static $plugin_basename;
170
- if ( !$plugin_basename ) $plugin_basename = plugin_basename(__FILE__);
171
- $settings_link = '<a href="options-general.php?page='.$plugin_basename.'">' . __('Settings') . '</a>';
172
  array_unshift( $action_links, $settings_link );
173
-
174
  return $action_links;
175
  }
176
 
177
- function phpmailer_init($phpmailer) {
178
  $options = $this->get_options();
179
  $phpmailer->IsSMTP();
180
  $phpmailer->Host = $options['host'];
181
  $phpmailer->Port = $options['port'] ? $options['port'] : 25;
182
  $phpmailer->SMTPAuth = $options['smtp_auth'] ? $options['smtp_auth'] : false;
183
- if ($phpmailer->SMTPAuth) {
184
  $phpmailer->Username = $options['smtp_user'];
185
  $phpmailer->Password = $options['smtp_pass'];
186
  }
187
- if ($options['smtp_secure'] != '')
188
  $phpmailer->SMTPSecure = $options['smtp_secure'];
189
- if ($options['wordwrap'] > 0 )
190
  $phpmailer->WordWrap = $options['wordwrap'];
191
  return $phpmailer;
192
  }
193
 
194
- function wp_mail_from($from) {
195
  $options = $this->get_options();
196
- if ($options['from_email'])
197
  $from = $options['from_email'];
198
- return $from;
199
  }
200
 
201
- function wp_mail_from_name($from_name) {
202
  $options = $this->get_options();
203
- if ($options['from_name'])
204
- $from_name = $options['from_name'];
205
  return $from_name;
206
  }
207
 
208
  function get_options() {
209
- if ( !empty($this->options)) return $this->options;
210
  // Derive options from the config
211
  $options = array();
212
  foreach (array_keys($this->config) as $opt) {
213
  $options[$opt] = $this->config[$opt]['default'];
214
  }
215
- $existing_options = get_option($this->admin_options_name);
216
- if (!empty($existing_options)) {
217
- foreach ($existing_options as $key => $value)
218
- $options[$key] = $value;
219
- }
220
  $this->options = $options;
221
- return $options;
222
  }
223
 
224
  function options_page() {
225
- static $plugin_basename;
226
- if ( !$plugin_basename ) $plugin_basename = plugin_basename(__FILE__);
227
  $options = $this->get_options();
228
  // See if user has submitted form
229
  if ( isset($_POST['submitted']) ) {
@@ -232,63 +230,59 @@ JS;
232
  foreach (array_keys($options) AS $opt) {
233
  $options[$opt] = htmlspecialchars(stripslashes($_POST[$opt]));
234
  $input = $this->config[$opt]['input'];
235
- if (($input == 'checkbox') && !$options[$opt])
236
  $options[$opt] = 0;
237
- if ($this->config[$opt]['datatype'] == 'array') {
238
- if ($input == 'text')
239
  $options[$opt] = explode(',', str_replace(array(', ', ' ', ','), ',', $options[$opt]));
240
  else
241
  $options[$opt] = array_map('trim', explode("\n", trim($options[$opt])));
242
  }
243
- elseif ($this->config[$opt]['datatype'] == 'hash') {
244
  if ( !empty($options[$opt]) ) {
245
  $new_values = array();
246
  foreach (explode("\n", $options[$opt]) AS $line) {
247
  list($shortcut, $text) = array_map('trim', explode("=>", $line, 2));
248
- if (!empty($shortcut)) $new_values[str_replace('\\', '', $shortcut)] = str_replace('\\', '', $text);
249
  }
250
  $options[$opt] = $new_values;
251
  }
252
  }
253
  }
254
  // If GMail is to be used, those settings take precendence
255
- if ($options['use_gmail'])
256
  $options = wp_parse_args($this->gmail_config, $options);
257
 
258
  // Remember to put all the other options into the array or they'll get lost!
259
  update_option($this->admin_options_name, $options);
260
-
261
- echo "<div id='message' class='updated fade'><p><strong>" . __('Settings saved') . '</strong></p></div>';
262
  }
263
  elseif ( isset($_POST['submit_test_email']) ) {
264
  check_admin_referer($this->nonce_field);
265
  $user = wp_get_current_user();
266
  $email = $user->user_email;
267
  $timestamp = current_time('mysql');
268
- $message = <<<END
269
- Hi, this is the {$this->plugin_name} plugin e-mailing you a test message from your WordPress blog.
270
-
271
- This message was sent with this time-stamp: $timestamp
272
-
273
- Congratulations! Your blog is properly configured to send e-mail.
274
- END;
275
- wp_mail($email, "Test message from your WordPress blog", $message);
276
- //echo "<div class='updated'>I would have sent $email this message:<br />$message</div>";
277
- echo "<div class='updated'><p>Test e-mail sent.</p><p>The body of the e-mail includes this time-stamp: $timestamp.</p></div>";
278
  }
279
 
280
- $action_url = $_SERVER[PHP_SELF] . '?page=' . $plugin_basename;
281
- $logo = get_option('siteurl') . '/wp-content/plugins/' . basename($_GET['page'], '.php') . '/c2c_minilogo.png';
282
 
283
- echo <<<END
284
- <div class='wrap'>
285
- <div class="icon32" style="width:44px;"><img src='$logo' alt='A plugin by coffee2code' /><br /></div>
286
- <h2>{$this->plugin_name} Settings</h2>
287
- <p>After you've configured your SMTP settings, use the <a href="#test">test</a> to send a test message to yourself.</p>
288
-
289
- <form name="configure_smtp" action="$action_url" method="post">
290
- END;
291
- wp_nonce_field($this->nonce_field);
292
  echo '<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform form-table">';
293
  foreach (array_keys($options) as $opt) {
294
  $input = $this->config[$opt]['input'];
@@ -342,14 +336,15 @@ END;
342
  }
343
  echo "</td></tr>";
344
  }
 
345
  echo <<<END
346
  </table>
347
  <input type="hidden" name="submitted" value="1" />
348
- <div class="submit"><input type="submit" name="Submit" class="button-primary" value="Save Changes" /></div>
349
  </form>
350
  </div>
351
  END;
352
- echo <<<END
353
  <style type="text/css">
354
  #c2c {
355
  text-align:center;
@@ -375,43 +370,39 @@ END;
375
  </style>
376
  <div id='c2c' class='wrap'>
377
  <div>
378
- This plugin brought to you by <a href="http://coffee2code.com" title="coffee2code.com">Scott Reilly, aka coffee2code</a>.
379
- <span><a href="http://coffee2code.com/donate" title="Please consider a donation">Did you find this plugin useful?</a></span>
380
- </div>
381
- </div>
382
  END;
 
 
 
 
 
 
383
  $user = wp_get_current_user();
384
  $email = $user->user_email;
385
- echo <<<END
386
- <div class='wrap'>
387
- <h2><a name="test"></a>Send A Test</h2>
388
- <p>Click the button below to send a test email to yourself to see if things are working. Be sure to save
389
- any changes you made to the form above before sending the test e-mail. Bear in mind it may take a few
390
- minutes for the e-mail to wind its way through the internet.</p>
391
-
392
- <p>This e-mail will be sent to your e-mail address, $email.</p>
393
-
394
- <form name="configure_smtp" action="$action_url" method="post">
395
- END;
396
- wp_nonce_field($this->nonce_field);
397
- echo <<<END
398
- <input type="hidden" name="submit_test_email" value="1" />
399
- <div class="submit"><input type="submit" name="Submit" value="Send test e-mail" /></div>
400
- </form>
401
- </div>
402
- END;
403
  }
404
 
405
  } // end ConfigureSMTP
406
 
407
  endif; // end if !class_exists()
408
- if ( class_exists('ConfigureSMTP') ) :
409
- // Get the ball rolling
410
- $configure_smtp = new ConfigureSMTP();
411
- // Actions and filters
412
- if (isset($configure_smtp)) {
413
- register_activation_hook( __FILE__, array(&$configure_smtp, 'install') );
 
414
  }
415
- endif;
 
 
 
416
 
417
  ?>
1
  <?php
2
  /*
3
  Plugin Name: Configure SMTP
4
+ Version: 2.7
5
  Plugin URI: http://coffee2code.com/wp-plugins/configure-smtp
6
  Author: Scott Reilly
7
  Author URI: http://coffee2code.com
8
+ Description: Configure SMTP mailing in WordPress, including support for sending e-mail via SSL/TLS (such as GMail).
9
 
10
  This plugin is the renamed, rewritten, and updated version of the wpPHPMailer plugin.
11
 
29
  A simple test button is also available that allows you to send a test e-mail to yourself to check if sending
30
  e-mail has been properly configured for your blog.
31
 
32
+ Compatible with WordPress 2.8+, 2.9+.
33
 
34
  =>> Read the accompanying readme.txt file for more information. Also, visit the plugin's homepage
35
  =>> for more information and the latest updates
37
  Installation:
38
 
39
  1. Download the file http://coffee2code.com/wp-plugins/configure-smtp.zip and unzip it into your
40
+ /wp-content/plugins/ directory (or install via the built-in WordPress plugin installer).
41
  2. Activate the plugin through the 'Plugins' admin menu in WordPress.
42
  3. Click the plugin's 'Settings' link next to its 'Deactivate' link (still on the Plugins page), or click on the
43
  Settings -> SMTP link, to go to the plugin's admin settings page. Optionally customize the settings (to configure it
47
  */
48
 
49
  /*
50
+ Copyright (c) 2004-2010 by Scott Reilly (aka coffee2code)
51
 
52
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
53
  files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
65
  if ( !class_exists('ConfigureSMTP') ) :
66
 
67
  class ConfigureSMTP {
 
68
  var $admin_options_name = 'c2c_configure_smtp';
69
  var $nonce_field = 'update-configure_smtp';
70
+ var $textdomain = 'configure-smtp';
71
  var $show_admin = true; // Change this to false if you don't want the plugin's admin page shown.
72
+ var $plugin_name = '';
73
+ var $short_name = '';
74
+ var $plugin_basename = '';
75
+ var $config = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  var $gmail_config = array(
77
  'host' => 'smtp.gmail.com',
78
  'port' => '465',
82
  var $options = array(); // Don't use this directly
83
 
84
  function ConfigureSMTP() {
85
+ global $pagenow;
86
+ $this->plugin_name = __('Configure SMTP', $this->textdomain);
87
+ $this->short_name = __('SMTP', $this->textdomain);
88
+ $this->plugin_basename = plugin_basename(__FILE__);
89
+ $this->config = array(
90
+ // input can be 'checkbox', 'short_text', 'text', 'textarea', 'inline_textarea', 'select', 'hidden', 'password', or 'none'
91
+ // an input type of 'select' must then have an 'options' value (an array) specified
92
+ // datatype can be 'array' or 'hash'
93
+ // can also specify input_attributes
94
+ 'use_gmail' => array('input' => 'checkbox', 'default' => false,
95
+ 'label' => __('Send e-mail via GMail?', $this->textdomain),
96
+ 'help' => __('Clicking this will override many of the settings defined below. You will need to input your GMail username and password below.', $this->textdomain),
97
+ 'input_attributes' => 'onclick="return configure_gmail();"'),
98
+ 'host' => array('input' => 'text', 'default' => 'localhost',
99
+ 'label' => __('SMTP host', $this->textdomain),
100
+ 'help' => __('If "localhost" doesn\'t work for you, check with your host for the SMTP hostname.', $this->textdomain)),
101
+ 'port' => array('input' => 'short_text', 'default' => 25,
102
+ 'label' => __('SMTP port', $this->textdomain),
103
+ 'help' => __('This is generally 25.', $this->textdomain)),
104
+ 'smtp_secure' => array('input' => 'select', 'default' => 'None',
105
+ 'label' => __('Secure connection prefix', $this->textdomain),
106
+ 'options' => array('', 'ssl', 'tls'),
107
+ 'help' => __('Sets connection prefix for secure connections (prefix method must be supported by your PHP install and your SMTP host)', $this->textdomain)),
108
+ 'smtp_auth' => array('input' => 'checkbox', 'default' => false,
109
+ 'label' => __('Use SMTPAuth?', $this->textdomain),
110
+ 'help' => __('If checked, you must provide the SMTP username and password below', $this->textdomain)),
111
+ 'smtp_user' => array('input' => 'text', 'default' => '',
112
+ 'label' => __('SMTP username', $this->textdomain),
113
+ 'help' => ''),
114
+ 'smtp_pass' => array('input' => 'password', 'default' => '',
115
+ 'label' => __('SMTP password', $this->textdomain),
116
+ 'help' => ''),
117
+ 'wordwrap' => array('input' => 'short_text', 'default' => '',
118
+ 'label' => __('Wordwrap length', $this->textdomain),
119
+ 'help' => __('Sets word wrapping on the body of the message to a given number of characters.', $this->textdomain)),
120
+ 'from_email' => array('input' => 'text', 'default' => '',
121
+ 'label' => __('Sender e-mail', $this->textdomain),
122
+ 'help' => __('Sets the From email address for all outgoing messages. Leave blank to use the WordPress default. This value will be used even if you don\'t enable SMTP. NOTE: This may not take effect depending on your mail server and settings, especially if using SMTPAuth (such as for GMail).', $this->textdomain)),
123
+ 'from_name' => array('input' => 'text', 'default' => '',
124
+ 'label' => __('Sender name', $this->textdomain),
125
+ 'help' => __('Sets the From name for all outgoing messages. Leave blank to use the WordPress default. This value will be used even if you don\'t enable SMTP.', $this->textdomain))
126
+ );
127
+
128
+ add_action('activate_' . str_replace(trailingslashit(WP_PLUGIN_DIR), '', __FILE__), array(&$this, 'install'));
129
+ if ( 'options-general.php' == $pagenow )
130
+ add_action('admin_footer', array(&$this, 'add_js'));
131
  add_action('admin_menu', array(&$this, 'admin_menu'));
132
  add_action('phpmailer_init', array(&$this, 'phpmailer_init'));
133
  add_action('wp_mail_from', array(&$this, 'wp_mail_from'));
140
  }
141
 
142
  function add_js() {
143
+ $alert = __('Be sure to specify your GMail email address (with the @gmail.com) as the SMTP username, and your GMail password as the SMTP password.', $this->textdomain);
144
  echo <<<JS
145
  <script type="text/javascript">
146
  function configure_gmail() {
152
  if (!jQuery('#smtp_user').val().match(/.+@gmail.com$/) ) {
153
  jQuery('#smtp_user').val('USERNAME@gmail.com').focus().get(0).setSelectionRange(0,8);
154
  }
155
+ alert('{$alert}');
156
  return true;
157
  }
158
  }
162
  }
163
 
164
  function admin_menu() {
165
+ if ( $this->show_admin && current_user_can('manage_options') ) {
166
+ add_filter( 'plugin_action_links_' . $this->plugin_basename, array(&$this, 'plugin_action_links') );
167
+ add_options_page($this->plugin_name, $this->short_name, 'manage_options', $this->plugin_basename, array(&$this, 'options_page'));
 
 
 
 
 
 
168
  }
169
  }
170
 
171
+ function plugin_action_links( $action_links ) {
172
+ $settings_link = '<a href="options-general.php?page='.$this->plugin_basename.'">' . __('Settings', $this->textdomain) . '</a>';
 
 
173
  array_unshift( $action_links, $settings_link );
 
174
  return $action_links;
175
  }
176
 
177
+ function phpmailer_init( $phpmailer ) {
178
  $options = $this->get_options();
179
  $phpmailer->IsSMTP();
180
  $phpmailer->Host = $options['host'];
181
  $phpmailer->Port = $options['port'] ? $options['port'] : 25;
182
  $phpmailer->SMTPAuth = $options['smtp_auth'] ? $options['smtp_auth'] : false;
183
+ if ( $phpmailer->SMTPAuth ) {
184
  $phpmailer->Username = $options['smtp_user'];
185
  $phpmailer->Password = $options['smtp_pass'];
186
  }
187
+ if ( $options['smtp_secure'] != '' )
188
  $phpmailer->SMTPSecure = $options['smtp_secure'];
189
+ if ( $options['wordwrap'] > 0 )
190
  $phpmailer->WordWrap = $options['wordwrap'];
191
  return $phpmailer;
192
  }
193
 
194
+ function wp_mail_from( $from ) {
195
  $options = $this->get_options();
196
+ if ( $options['from_email'] )
197
  $from = $options['from_email'];
198
+ return $from;
199
  }
200
 
201
+ function wp_mail_from_name( $from_name ) {
202
  $options = $this->get_options();
203
+ if ( $options['from_name'] )
204
+ $from_name = htmlspecialchars_decode($options['from_name']);
205
  return $from_name;
206
  }
207
 
208
  function get_options() {
209
+ if ( !empty($this->options) ) return $this->options;
210
  // Derive options from the config
211
  $options = array();
212
  foreach (array_keys($this->config) as $opt) {
213
  $options[$opt] = $this->config[$opt]['default'];
214
  }
215
+ $existing_options = get_option($this->admin_options_name);
216
+ if ( !empty($existing_options) ) {
217
+ foreach ($existing_options as $key => $value)
218
+ $options[$key] = $value;
219
+ }
220
  $this->options = $options;
221
+ return $options;
222
  }
223
 
224
  function options_page() {
 
 
225
  $options = $this->get_options();
226
  // See if user has submitted form
227
  if ( isset($_POST['submitted']) ) {
230
  foreach (array_keys($options) AS $opt) {
231
  $options[$opt] = htmlspecialchars(stripslashes($_POST[$opt]));
232
  $input = $this->config[$opt]['input'];
233
+ if ( ($input == 'checkbox') && !$options[$opt] )
234
  $options[$opt] = 0;
235
+ if ( $this->config[$opt]['datatype'] == 'array' ) {
236
+ if ( $input == 'text' )
237
  $options[$opt] = explode(',', str_replace(array(', ', ' ', ','), ',', $options[$opt]));
238
  else
239
  $options[$opt] = array_map('trim', explode("\n", trim($options[$opt])));
240
  }
241
+ elseif ( $this->config[$opt]['datatype'] == 'hash' ) {
242
  if ( !empty($options[$opt]) ) {
243
  $new_values = array();
244
  foreach (explode("\n", $options[$opt]) AS $line) {
245
  list($shortcut, $text) = array_map('trim', explode("=>", $line, 2));
246
+ if ( !empty($shortcut) ) $new_values[str_replace('\\', '', $shortcut)] = str_replace('\\', '', $text);
247
  }
248
  $options[$opt] = $new_values;
249
  }
250
  }
251
  }
252
  // If GMail is to be used, those settings take precendence
253
+ if ( $options['use_gmail'] )
254
  $options = wp_parse_args($this->gmail_config, $options);
255
 
256
  // Remember to put all the other options into the array or they'll get lost!
257
  update_option($this->admin_options_name, $options);
258
+ $this->options = $options;
259
+ echo "<div id='message' class='updated fade'><p><strong>" . __('Settings saved', $this->textdomain) . '</strong></p></div>';
260
  }
261
  elseif ( isset($_POST['submit_test_email']) ) {
262
  check_admin_referer($this->nonce_field);
263
  $user = wp_get_current_user();
264
  $email = $user->user_email;
265
  $timestamp = current_time('mysql');
266
+
267
+ $message = sprintf(__('Hi, this is the %s plugin e-mailing you a test message from your WordPress blog.', $this->textdomain), $this->plugin_name);
268
+ $message .= "\n\n";
269
+ $message .= sprintf(__('This message was sent with this time-stamp: %s', $this->textdomain), $timestamp);
270
+ $message .= "\n\n";
271
+ $message .= __('Congratulations! Your blog is properly configured to send e-mail.', $this->textdomain);
272
+ wp_mail($email, __('Test message from your WordPress blog', $this->textdomain), $message);
273
+ echo '<div class="updated"><p>' . __('Test e-mail sent.', $this->textdomain) . '</p>';
274
+ echo '<p>' . sprintf(__('The body of the e-mail includes this time-stamp: %s.', $this->textdomain), $timestamp) . '</p></div>';
 
275
  }
276
 
277
+ $action_url = $_SERVER['PHP_SELF'] . '?page=' . $this->plugin_basename;
278
+ $logo = plugins_url(basename($_GET['page'], '.php') . '/c2c_minilogo.png');
279
 
280
+ echo "<div class='wrap'><div class='icon32' style='width:44px;'><img src='$logo' alt='" . esc_attr__('A plugin by coffee2code', $this->textdomain) . "' /><br /></div>";
281
+ echo '<h2>' . __('Configure SMTP Settings', $this->textdomain) . '</h2>';
282
+ $str = '<a href="#test">' . __('test', $this->textdomain) . '</a>';
283
+ echo '<p>' . sprintf(__('After you\'ve configured your SMTP settings, use the %s to send a test message to yourself.', $this->textdomain), $str) . '</p>';
284
+ echo "<form name='configure_smtp' action='$action_url' method='post'>";
285
+ wp_nonce_field($this->nonce_field);
 
 
 
286
  echo '<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform form-table">';
287
  foreach (array_keys($options) as $opt) {
288
  $input = $this->config[$opt]['input'];
336
  }
337
  echo "</td></tr>";
338
  }
339
+ $txt = __('Save Changes', $this->textdomain);
340
  echo <<<END
341
  </table>
342
  <input type="hidden" name="submitted" value="1" />
343
+ <div class="submit"><input type="submit" name="Submit" class="button-primary" value="{$txt}" /></div>
344
  </form>
345
  </div>
346
  END;
347
+ echo <<<END
348
  <style type="text/css">
349
  #c2c {
350
  text-align:center;
370
  </style>
371
  <div id='c2c' class='wrap'>
372
  <div>
 
 
 
 
373
  END;
374
+ $c2c = '<a href="http://coffee2code.com" title="coffee2code.com">' . __('Scott Reilly, aka coffee2code', $this->textdomain) . '</a>';
375
+ echo sprintf(__('This plugin brought to you by %s.', $this->textdomain), $c2c);
376
+ echo '<span><a href="http://coffee2code.com/donate" title="' . esc_attr__('Please consider a donation', $this->textdomain) . '">' .
377
+ __('Did you find this plugin useful?', $this->textdomain) . '</a></span>';
378
+ echo '</div></div>';
379
+
380
  $user = wp_get_current_user();
381
  $email = $user->user_email;
382
+ echo '<div class="wrap"><h2><a name="test"></a>' . __('Send A Test', $this->textdomain) . "</h2>\n";
383
+ echo '<p>' . __('Click the button below to send a test email to yourself to see if things are working. Be sure to save any changes you made to the form above before sending the test e-mail. Bear in mind it may take a few minutes for the e-mail to wind its way through the internet.', $this->textdomain) . "</p>\n";
384
+ echo '<p>' . sprintf(__('This e-mail will be sent to your e-mail address, %s.', $this->textdomain), $email) . "</p>\n";
385
+ echo "<form name='configure_smtp' action='$action_url' method='post'>\n";
386
+ wp_nonce_field($this->nonce_field);
387
+ echo '<input type="hidden" name="submit_test_email" value="1" />';
388
+ echo '<div class="submit"><input type="submit" name="Submit" value="' . esc_attr__('Send test e-mail', $this->textdomain) . '" /></div>';
389
+ echo '</form></div>';
 
 
 
 
 
 
 
 
 
 
390
  }
391
 
392
  } // end ConfigureSMTP
393
 
394
  endif; // end if !class_exists()
395
+
396
+ // This function was introduced in PHP5. Backcomp via http://php.net/manual/en/function.htmlspecialchars-decode.php
397
+ if ( !function_exists('htmlspecialchars_decode') ) {
398
+ function htmlspecialchars_decode( $string, $quote_style = ENT_COMPAT ) {
399
+ $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style));
400
+ if ( $quote_style === ENT_QUOTES ) { $translation['&#039;'] = '\''; }
401
+ return strtr($string, $translation);
402
  }
403
+ }
404
+
405
+ if ( class_exists('ConfigureSMTP') )
406
+ new ConfigureSMTP();
407
 
408
  ?>
configure-smtp.pot ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of the WordPress plugin Configure SMTP 2.7 by Scott Reilly.
2
+ # Copyright (C) 2009 Scott Reilly
3
+ # This file is distributed under the same license as the Configure SMTP package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, 2009.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: Configure SMTP 2.7\n"
10
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/configure-smtp\n"
11
+ "POT-Creation-Date: 2009-12-31 10:09-0600\n"
12
+ "PO-Revision-Date: 2009-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=utf-8\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+
19
+ #. #-#-#-#-# configure-smtp.pot (Configure SMTP 2.7) #-#-#-#-#
20
+ #. Plugin Name of an extension
21
+ #: configure-smtp.php:86
22
+ msgid "Configure SMTP"
23
+ msgstr ""
24
+
25
+ #: configure-smtp.php:87
26
+ msgid "SMTP"
27
+ msgstr ""
28
+
29
+ #: configure-smtp.php:95
30
+ msgid "Send e-mail via GMail?"
31
+ msgstr ""
32
+
33
+ #: configure-smtp.php:96
34
+ msgid ""
35
+ "Clicking this will override many of the settings defined below. You will "
36
+ "need to input your GMail username and password below."
37
+ msgstr ""
38
+
39
+ #: configure-smtp.php:99
40
+ msgid "SMTP host"
41
+ msgstr ""
42
+
43
+ #: configure-smtp.php:100
44
+ msgid ""
45
+ "If \"localhost\" doesn't work for you, check with your host for the SMTP "
46
+ "hostname."
47
+ msgstr ""
48
+
49
+ #: configure-smtp.php:102
50
+ msgid "SMTP port"
51
+ msgstr ""
52
+
53
+ #: configure-smtp.php:103
54
+ msgid "This is generally 25."
55
+ msgstr ""
56
+
57
+ #: configure-smtp.php:105
58
+ msgid "Secure connection prefix"
59
+ msgstr ""
60
+
61
+ #: configure-smtp.php:107
62
+ msgid ""
63
+ "Sets connection prefix for secure connections (prefix method must be "
64
+ "supported by your PHP install and your SMTP host)"
65
+ msgstr ""
66
+
67
+ #: configure-smtp.php:109
68
+ msgid "Use SMTPAuth?"
69
+ msgstr ""
70
+
71
+ #: configure-smtp.php:110
72
+ msgid "If checked, you must provide the SMTP username and password below"
73
+ msgstr ""
74
+
75
+ #: configure-smtp.php:112
76
+ msgid "SMTP username"
77
+ msgstr ""
78
+
79
+ #: configure-smtp.php:115
80
+ msgid "SMTP password"
81
+ msgstr ""
82
+
83
+ #: configure-smtp.php:118
84
+ msgid "Wordwrap length"
85
+ msgstr ""
86
+
87
+ #: configure-smtp.php:119
88
+ msgid ""
89
+ "Sets word wrapping on the body of the message to a given number of "
90
+ "characters."
91
+ msgstr ""
92
+
93
+ #: configure-smtp.php:121
94
+ msgid "Sender e-mail"
95
+ msgstr ""
96
+
97
+ #: configure-smtp.php:122
98
+ msgid ""
99
+ "Sets the From email address for all outgoing messages. Leave blank to use "
100
+ "the WordPress default. This value will be used even if you don't enable "
101
+ "SMTP. NOTE: This may not take effect depending on your mail server and "
102
+ "settings, especially if using SMTPAuth (such as for GMail)."
103
+ msgstr ""
104
+
105
+ #: configure-smtp.php:124
106
+ msgid "Sender name"
107
+ msgstr ""
108
+
109
+ #: configure-smtp.php:125
110
+ msgid ""
111
+ "Sets the From name for all outgoing messages. Leave blank to use the "
112
+ "WordPress default. This value will be used even if you don't enable SMTP."
113
+ msgstr ""
114
+
115
+ #: configure-smtp.php:143
116
+ msgid ""
117
+ "Be sure to specify your GMail email address (with the @gmail.com) as the "
118
+ "SMTP username, and your GMail password as the SMTP password."
119
+ msgstr ""
120
+
121
+ #: configure-smtp.php:172
122
+ msgid "Settings"
123
+ msgstr ""
124
+
125
+ #: configure-smtp.php:259
126
+ msgid "Settings saved"
127
+ msgstr ""
128
+
129
+ #: configure-smtp.php:267
130
+ #, php-format
131
+ msgid ""
132
+ "Hi, this is the %s plugin e-mailing you a test message from your WordPress "
133
+ "blog."
134
+ msgstr ""
135
+
136
+ #: configure-smtp.php:269
137
+ #, php-format
138
+ msgid "This message was sent with this time-stamp: %s"
139
+ msgstr ""
140
+
141
+ #: configure-smtp.php:271
142
+ msgid "Congratulations! Your blog is properly configured to send e-mail."
143
+ msgstr ""
144
+
145
+ #: configure-smtp.php:272
146
+ msgid "Test message from your WordPress blog"
147
+ msgstr ""
148
+
149
+ #: configure-smtp.php:273
150
+ msgid "Test e-mail sent."
151
+ msgstr ""
152
+
153
+ #: configure-smtp.php:274
154
+ #, php-format
155
+ msgid "The body of the e-mail includes this time-stamp: %s."
156
+ msgstr ""
157
+
158
+ #: configure-smtp.php:280
159
+ msgid "A plugin by coffee2code"
160
+ msgstr ""
161
+
162
+ #: configure-smtp.php:281
163
+ msgid "Configure SMTP Settings"
164
+ msgstr ""
165
+
166
+ #: configure-smtp.php:282
167
+ msgid "test"
168
+ msgstr ""
169
+
170
+ #: configure-smtp.php:283
171
+ #, php-format
172
+ msgid ""
173
+ "After you've configured your SMTP settings, use the %s to send a test "
174
+ "message to yourself."
175
+ msgstr ""
176
+
177
+ #: configure-smtp.php:339
178
+ msgid "Save Changes"
179
+ msgstr ""
180
+
181
+ #: configure-smtp.php:382
182
+ msgid "Send A Test"
183
+ msgstr ""
184
+
185
+ #: configure-smtp.php:383
186
+ msgid ""
187
+ "Click the button below to send a test email to yourself to see if things are "
188
+ "working. Be sure to save any changes you made to the form above before "
189
+ "sending the test e-mail. Bear in mind it may take a few minutes for the e-"
190
+ "mail to wind its way through the internet."
191
+ msgstr ""
192
+
193
+ #: configure-smtp.php:384
194
+ #, php-format
195
+ msgid "This e-mail will be sent to your e-mail address, %s."
196
+ msgstr ""
197
+
198
+ #: configure-smtp.php:388
199
+ msgid "Send test e-mail"
200
+ msgstr ""
201
+
202
+ #. Plugin URI of an extension
203
+ msgid "http://coffee2code.com/wp-plugins/configure-smtp"
204
+ msgstr ""
205
+
206
+ #. Description of an extension
207
+ msgid ""
208
+ "Configure SMTP mailing in WordPress, including support for sending e-mail "
209
+ "via SSL/TLS (such as GMail)."
210
+ msgstr ""
211
+
212
+ #. Author of an extension
213
+ msgid "Scott Reilly"
214
+ msgstr ""
215
+
216
+ #. Author URI of an extension
217
+ msgid "http://coffee2code.com"
218
+ msgstr ""
readme.txt CHANGED
@@ -1,11 +1,11 @@
1
  === Configure SMTP ===
2
  Contributors: coffee2code
3
  Donate link: http://coffee2code.com/donate
4
- Tags: email, smtp, gmail, sendmail, wp_mail, phpmailer, outgoing mail, coffee2code
5
- Requires at least: 2.2
6
- Tested up to: 2.7.1
7
- Stable tag: 2.5
8
- Version: 2.5
9
 
10
  Configure SMTP mailing in WordPress, including support for sending e-mail via SSL/TLS (such as GMail).
11
 
@@ -26,18 +26,18 @@ Use this plugin to customize the SMTP mailing system used by default by WordPres
26
 
27
  In addition, you can instead indicate that you wish to use GMail to handle outgoing e-mail, in which case the above settings are automatically configured to values appropriate for GMail, though you'll need to specify your GMail e-mail (including the "@gmail.com") and password.
28
 
29
- Regardless of whether SMTP is enabled, the plugin provides you the ability to define the name and email of the 'From:' field for all outgoing e-mails.
30
 
31
  A simple test button is also available that allows you to send a test e-mail to yourself to check if sending e-mail has been properly configured for your blog.
32
 
33
  == Installation ==
34
 
35
- 1. Unzip `configure-smtp.zip` inside the `/wp-content/plugins/` directory
36
  1. Activate the plugin through the 'Plugins' admin menu in WordPress
37
  1. Click the plugin's `Settings` link next to its `Deactivate` link (still on the Plugins page), or click on the `Settings` -> `SMTP` link, to go to the plugin's admin settings page. Optionally customize the settings (to configure it if the defaults aren't valid for your situation).
38
  1. (optional) Use the built-in test to see if your blog can properly send out e-mails.
39
 
40
- == Frequently Asked Questions =
41
 
42
  = I am already able to receive e-mail sent by my blog, so would I have any use or need for this plugin? =
43
 
@@ -49,8 +49,54 @@ Check out the settings for your local e-mail program. More than likely that is
49
 
50
  = I've sent out a few test e-mails using the test button after having tried different values for some of the settings; how do I know which one worked? =
51
 
52
- If your settings worked, you should receive the test e-mail at e-mail address associated with your WordPress blog user account. That e-mail contains a time-stamp which was reported to you by the plugin when the e-mail was sent. If you are trying out various setting values, be sure to record what your settings were and what the time-stamp was when sending with those settings.
53
 
54
  == Screenshots ==
55
 
56
- 1. A screenshot of the plugin's admin settings page.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  === Configure SMTP ===
2
  Contributors: coffee2code
3
  Donate link: http://coffee2code.com/donate
4
+ Tags: email, smtp, gmail, sendmail, wp_mail, phpmailer, outgoing mail, tls, ssl, security, privacy, wp-phpmailer, coffee2code
5
+ Requires at least: 2.8
6
+ Tested up to: 2.9.1
7
+ Stable tag: 2.7
8
+ Version: 2.7
9
 
10
  Configure SMTP mailing in WordPress, including support for sending e-mail via SSL/TLS (such as GMail).
11
 
26
 
27
  In addition, you can instead indicate that you wish to use GMail to handle outgoing e-mail, in which case the above settings are automatically configured to values appropriate for GMail, though you'll need to specify your GMail e-mail (including the "@gmail.com") and password.
28
 
29
+ Regardless of whether SMTP is enabled, the plugin provides you the ability to define the name and e-mail of the 'From:' field for all outgoing e-mails.
30
 
31
  A simple test button is also available that allows you to send a test e-mail to yourself to check if sending e-mail has been properly configured for your blog.
32
 
33
  == Installation ==
34
 
35
+ 1. Unzip `configure-smtp.zip` inside the `/wp-content/plugins/` directory (or install via the built-in WordPress plugin installer)
36
  1. Activate the plugin through the 'Plugins' admin menu in WordPress
37
  1. Click the plugin's `Settings` link next to its `Deactivate` link (still on the Plugins page), or click on the `Settings` -> `SMTP` link, to go to the plugin's admin settings page. Optionally customize the settings (to configure it if the defaults aren't valid for your situation).
38
  1. (optional) Use the built-in test to see if your blog can properly send out e-mails.
39
 
40
+ == Frequently Asked Questions ==
41
 
42
  = I am already able to receive e-mail sent by my blog, so would I have any use or need for this plugin? =
43
 
49
 
50
  = I've sent out a few test e-mails using the test button after having tried different values for some of the settings; how do I know which one worked? =
51
 
52
+ If your settings worked, you should receive the test e-mail at the e-mail address associated with your WordPress blog user account. That e-mail contains a time-stamp which was reported to you by the plugin when the e-mail was sent. If you are trying out various setting values, be sure to record what your settings were and what the time-stamp was when sending with those settings.
53
 
54
  == Screenshots ==
55
 
56
+ 1. A screenshot of the plugin's admin settings page.
57
+
58
+ == Changelog ==
59
+
60
+ = 2.7 =
61
+ * Fix to prevent HTML entities from appearing in the From name value in outgoing e-mails
62
+ * Added full support for localization
63
+ * Added .pot file
64
+ * Noted that overriding the From e-mail value may not take effect depending on mail server and settings, particular if SMTPAuth is used (i.e. GMail)
65
+ * Changed invocation of plugin's install function to action hooked in constructor rather than in global space
66
+ * Update object's option buffer after saving changed submitted by user
67
+ * Miscellaneous tweaks to update plugin to my current plugin conventions
68
+ * Noted compatibility with WP2.9+
69
+ * Dropped compatibility with versions of WP older than 2.8
70
+ * Updated readme.txt
71
+ * Updated copyright date
72
+
73
+ = 2.6 =
74
+ * Now show settings page JS in footer, and only on the admin settings page
75
+ * Removed hardcoded path to plugins dir
76
+ * Changed permission check
77
+ * Minor reformatting (added spaces)
78
+ * Tweaked readme.txt
79
+ * Removed compatibility with versions of WP older than 2.6
80
+ * Noted compatibility with WP 2.8+
81
+
82
+ = 2.5 =
83
+ * NEW
84
+ * Added support for GMail, including configuring the various settings to be appropriate for GMail
85
+ * Added support for SMTPSecure setting (acceptable values of '', 'ssl', or 'tls')
86
+ * Added "Settings" link next to "Activate"/"Deactivate" link next to the plugin on the admin plugin listings page
87
+ * CHANGED
88
+ * Tweaked plugin's admin options page to conform to newer WP 2.7 style
89
+ * Tweaked test e-mail subject and body
90
+ * Removed the use_smtp option since WP uses SMTP by default, the plugin can't help you if it isn't using SMTP already, and the plugin should just go ahead and apply if it is active
91
+ * Updated description, installation instructions, extended description, copyright
92
+ * Extended compatibility to WP 2.7+
93
+ * Facilitated translation of some text
94
+ * FIXED
95
+ * Fixed bug where specified wordwrap value wasn't taken into account
96
+
97
+ = 2.0 =
98
+ * Initial release after rewrite from wpPHPMailer
99
+
100
+ = pre-2.0 =
101
+ * Earlier versions of this plugin existed as my wpPHPMailer plugin, which due to the inclusion of PHPMailer within WordPress's core and necessary changes to the plugin warranted a rebranding/renaming.
102
+