Version Description
Download this release
Release Info
| Developer | chmac |
| Plugin | |
| Version | 0.4 |
| Comparing to | |
| See all releases | |
Code changes from version 0.3.2 to 0.4
- readme.txt +2 -2
- wp-mail-smtp/wp_mail_smtp.php → wp_mail_smtp.php +57 -23
readme.txt
CHANGED
|
@@ -3,8 +3,8 @@ Contributors: chmac
|
|
| 3 |
Donate link: http://www.callum-macdonald.com/code/donate/
|
| 4 |
Tags: mail, smtp, wp_mail, mailer, phpmailer
|
| 5 |
Requires at least: 2.0
|
| 6 |
-
Tested up to: 2.
|
| 7 |
-
Stable tag: 0.
|
| 8 |
|
| 9 |
Reconfigures the wp_mail() function to use SMTP instead of mail() and creates an options page to manage host, username, password, etc.
|
| 10 |
|
| 3 |
Donate link: http://www.callum-macdonald.com/code/donate/
|
| 4 |
Tags: mail, smtp, wp_mail, mailer, phpmailer
|
| 5 |
Requires at least: 2.0
|
| 6 |
+
Tested up to: 2.3
|
| 7 |
+
Stable tag: 0.4
|
| 8 |
|
| 9 |
Reconfigures the wp_mail() function to use SMTP instead of mail() and creates an options page to manage host, username, password, etc.
|
| 10 |
|
wp-mail-smtp/wp_mail_smtp.php → wp_mail_smtp.php
RENAMED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?php
|
| 2 |
/*
|
| 3 |
Plugin Name: WP-Mail-SMTP
|
| 4 |
-
Version: 0.
|
| 5 |
Plugin URI: http://www.callum-macdonald.com/code/wp-mail-smtp/
|
| 6 |
Description: Reconfigures the wp_mail() function to use SMTP instead of mail() and creates an options page to manage host, username, password, etc.
|
| 7 |
Author: Callum Macdonald
|
|
@@ -22,6 +22,7 @@ Author URI: http://www.callum-macdonald.com/
|
|
| 22 |
*
|
| 23 |
* CHANGELOG
|
| 24 |
*
|
|
|
|
| 25 |
* 0.3.2 - Changed to use register_activation_hook for greater compatability
|
| 26 |
* 0.3.1 - Added readme for WP-Plugins.org compatability
|
| 27 |
* 0.3 - Various bugfixes and added From options
|
|
@@ -34,9 +35,9 @@ $wpms_options = array (
|
|
| 34 |
'mail_from' => '',
|
| 35 |
'mailer' => 'smtp',
|
| 36 |
'smtp_host' => 'localhost',
|
| 37 |
-
'smtp_auth' =>
|
| 38 |
'smtp_user' => '',
|
| 39 |
-
'smtp_pass' => ''
|
| 40 |
);
|
| 41 |
|
| 42 |
/**
|
|
@@ -103,26 +104,47 @@ if (!function_exists('wp_mail_smtp_options_page')) {
|
|
| 103 |
// Load the options
|
| 104 |
global $wpms_options;
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
?>
|
| 107 |
<div class="wrap">
|
| 108 |
-
<h2><?php _e('Advanced Email Options') ?></h2>
|
| 109 |
<form method="post" action="options.php">
|
| 110 |
-
<?php wp_nonce_field('update-options') ?>
|
| 111 |
-
<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" />
|
| 112 |
<fieldset class="options">
|
| 113 |
-
<legend
|
| 114 |
<table class="optiontable">
|
| 115 |
<tr valign="top">
|
| 116 |
-
<th scope="row"><?php _e('From:') ?> </th>
|
| 117 |
<td><p><input name="mail_from" type="text" id="mail_from" value="<?php print(get_option('mail_from')); ?>" size="40" class="code" /><br />
|
| 118 |
<?php _e('You can specify just an email address or a name and email address in the form "Name<email@example.com>". If this is left blank or does not contain an @ symbol, the admin email will be used.'); ?></p></td>
|
| 119 |
</tr>
|
| 120 |
</table>
|
| 121 |
|
| 122 |
-
<legend
|
| 123 |
<table class="optiontable">
|
| 124 |
<tr valign="top">
|
| 125 |
-
<th scope="row"><?php _e('Mailer:') ?> </th>
|
| 126 |
<td>
|
| 127 |
<p><input id="mailer_smtp" type="radio" name="mailer" value="smtp" <?php checked('smtp', get_option('mailer')); ?> />
|
| 128 |
<label for="mailer_smtp"><?php _e('Send all WordPress emails via SMTP.'); ?></label></p>
|
|
@@ -132,15 +154,15 @@ if (!function_exists('wp_mail_smtp_options_page')) {
|
|
| 132 |
</tr>
|
| 133 |
</table>
|
| 134 |
|
| 135 |
-
<legend
|
| 136 |
<p><?php _e('These options only apply if you have chosen to send mail by SMTP above.'); ?></p>
|
| 137 |
<table class="optiontable">
|
| 138 |
<tr valign="top">
|
| 139 |
-
<th scope="row"><?php _e('SMTP Host:') ?> </th>
|
| 140 |
<td><input name="smtp_host" type="text" id="smtp_host" value="<?php print(get_option('smtp_host')); ?>" size="40" class="code" /></td>
|
| 141 |
</tr>
|
| 142 |
<tr valign="top">
|
| 143 |
-
<th scope="row"><?php _e('Authentication:') ?> </th>
|
| 144 |
<td>
|
| 145 |
<p><input id="smtp_auth_false" type="radio" name="smtp_auth" value="false" <?php checked('false', get_option('smtp_auth')); ?> />
|
| 146 |
<label for="smtp_auth_false"><?php _e('No: Do not use SMTP authentication.'); ?></label></p>
|
|
@@ -150,20 +172,34 @@ if (!function_exists('wp_mail_smtp_options_page')) {
|
|
| 150 |
</td>
|
| 151 |
</tr>
|
| 152 |
<tr valign="top">
|
| 153 |
-
<th scope="row"><?php _e('Username:') ?> </th>
|
| 154 |
<td><input name="smtp_user" type="text" id="smtp_user" value="<?php print(get_option('smtp_user')); ?>" size="40" class="code" /></td>
|
| 155 |
</tr>
|
| 156 |
<tr valign="top">
|
| 157 |
-
<th scope="row"><?php _e('Password:') ?> </th>
|
| 158 |
<td><input name="smtp_pass" type="text" id="smtp_pass" value="<?php print(get_option('smtp_pass')); ?>" size="40" class="code" /></td>
|
| 159 |
</tr>
|
| 160 |
</table>
|
| 161 |
-
</fieldset>
|
| 162 |
|
| 163 |
-
<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" />
|
| 164 |
<input type="hidden" name="action" value="update" />
|
| 165 |
</p>
|
| 166 |
<input type="hidden" name="page_options" value="<?php print(implode(',',array_keys($wpms_options))); ?>">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
</form>
|
| 168 |
|
| 169 |
</div>
|
|
@@ -197,9 +233,7 @@ if (!function_exists('wp_mail_smtp_mail_from')) {
|
|
| 197 |
|
| 198 |
/**
|
| 199 |
* //// CHMAC TODO
|
| 200 |
-
*
|
| 201 |
-
* using it, we'll need to strip the name out. Maybe it's quicker to
|
| 202 |
-
* copy the checks from is_email...
|
| 203 |
*/
|
| 204 |
|
| 205 |
// If we can, use the is_email function to verify the email
|
|
@@ -208,16 +242,16 @@ if (!function_exists('wp_mail_smtp_mail_from')) {
|
|
| 208 |
return(get_option('mail_from'));
|
| 209 |
}
|
| 210 |
else {
|
| 211 |
-
return (
|
| 212 |
}
|
| 213 |
}
|
| 214 |
// If is_email is not available, check there's an @ symbol
|
| 215 |
elseif (strpos(get_option('mail_from'),'@')) {
|
| 216 |
return(get_option('mail_from'));
|
| 217 |
}
|
| 218 |
-
// If there's no is_email and no @, use the
|
| 219 |
else {
|
| 220 |
-
return(
|
| 221 |
}
|
| 222 |
|
| 223 |
} // End of wp_mail_smtp_mail_from() function definition
|
| 1 |
<?php
|
| 2 |
/*
|
| 3 |
Plugin Name: WP-Mail-SMTP
|
| 4 |
+
Version: 0.4
|
| 5 |
Plugin URI: http://www.callum-macdonald.com/code/wp-mail-smtp/
|
| 6 |
Description: Reconfigures the wp_mail() function to use SMTP instead of mail() and creates an options page to manage host, username, password, etc.
|
| 7 |
Author: Callum Macdonald
|
| 22 |
*
|
| 23 |
* CHANGELOG
|
| 24 |
*
|
| 25 |
+
* 0.4 - Added the test email feature and cleaned up some other bits and pieces
|
| 26 |
* 0.3.2 - Changed to use register_activation_hook for greater compatability
|
| 27 |
* 0.3.1 - Added readme for WP-Plugins.org compatability
|
| 28 |
* 0.3 - Various bugfixes and added From options
|
| 35 |
'mail_from' => '',
|
| 36 |
'mailer' => 'smtp',
|
| 37 |
'smtp_host' => 'localhost',
|
| 38 |
+
'smtp_auth' => false,
|
| 39 |
'smtp_user' => '',
|
| 40 |
+
'smtp_pass' => ''
|
| 41 |
);
|
| 42 |
|
| 43 |
/**
|
| 104 |
// Load the options
|
| 105 |
global $wpms_options;
|
| 106 |
|
| 107 |
+
// Send a test mail if necessary
|
| 108 |
+
if (isset($_POST['wpms_action']) && $_POST['wpms_action'] == __('Send Test') && isset($_POST['to'])) {
|
| 109 |
+
|
| 110 |
+
// Set up the mail variables
|
| 111 |
+
$to = $_POST['to'];
|
| 112 |
+
$subject = "WP Mail SMTP: Test mail to " . $to;
|
| 113 |
+
$message = "This is a test email generated by the WP Mail SMTP WordPress plugin.";
|
| 114 |
+
|
| 115 |
+
// Send the test mail
|
| 116 |
+
$result = wp_mail($to,$subject,$message);
|
| 117 |
+
|
| 118 |
+
// Output the response
|
| 119 |
+
?>
|
| 120 |
+
<div id="message" class="updated fade"><p><strong><?php _e('Test Message Sent'); ?></strong></p>
|
| 121 |
+
<p><?php _e('The result was:'); ?></p>
|
| 122 |
+
<pre><?php var_dump($result); ?></pre>
|
| 123 |
+
</div>
|
| 124 |
+
<?php
|
| 125 |
+
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
?>
|
| 129 |
<div class="wrap">
|
| 130 |
+
<h2><?php _e('Advanced Email Options'); ?></h2>
|
| 131 |
<form method="post" action="options.php">
|
| 132 |
+
<?php wp_nonce_field('update-options'); ?>
|
| 133 |
+
<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options »'); ?>" />
|
| 134 |
<fieldset class="options">
|
| 135 |
+
<legend><?php _e('From'); ?></legend>
|
| 136 |
<table class="optiontable">
|
| 137 |
<tr valign="top">
|
| 138 |
+
<th scope="row"><?php _e('From:'); ?> </th>
|
| 139 |
<td><p><input name="mail_from" type="text" id="mail_from" value="<?php print(get_option('mail_from')); ?>" size="40" class="code" /><br />
|
| 140 |
<?php _e('You can specify just an email address or a name and email address in the form "Name<email@example.com>". If this is left blank or does not contain an @ symbol, the admin email will be used.'); ?></p></td>
|
| 141 |
</tr>
|
| 142 |
</table>
|
| 143 |
|
| 144 |
+
<legend><?php _e('Mailer'); ?></legend>
|
| 145 |
<table class="optiontable">
|
| 146 |
<tr valign="top">
|
| 147 |
+
<th scope="row"><?php _e('Mailer:'); ?> </th>
|
| 148 |
<td>
|
| 149 |
<p><input id="mailer_smtp" type="radio" name="mailer" value="smtp" <?php checked('smtp', get_option('mailer')); ?> />
|
| 150 |
<label for="mailer_smtp"><?php _e('Send all WordPress emails via SMTP.'); ?></label></p>
|
| 154 |
</tr>
|
| 155 |
</table>
|
| 156 |
|
| 157 |
+
<legend><?php _e('SMTP Options'); ?></legend>
|
| 158 |
<p><?php _e('These options only apply if you have chosen to send mail by SMTP above.'); ?></p>
|
| 159 |
<table class="optiontable">
|
| 160 |
<tr valign="top">
|
| 161 |
+
<th scope="row"><?php _e('SMTP Host:'); ?> </th>
|
| 162 |
<td><input name="smtp_host" type="text" id="smtp_host" value="<?php print(get_option('smtp_host')); ?>" size="40" class="code" /></td>
|
| 163 |
</tr>
|
| 164 |
<tr valign="top">
|
| 165 |
+
<th scope="row"><?php _e('Authentication:'); ?> </th>
|
| 166 |
<td>
|
| 167 |
<p><input id="smtp_auth_false" type="radio" name="smtp_auth" value="false" <?php checked('false', get_option('smtp_auth')); ?> />
|
| 168 |
<label for="smtp_auth_false"><?php _e('No: Do not use SMTP authentication.'); ?></label></p>
|
| 172 |
</td>
|
| 173 |
</tr>
|
| 174 |
<tr valign="top">
|
| 175 |
+
<th scope="row"><?php _e('Username:'); ?> </th>
|
| 176 |
<td><input name="smtp_user" type="text" id="smtp_user" value="<?php print(get_option('smtp_user')); ?>" size="40" class="code" /></td>
|
| 177 |
</tr>
|
| 178 |
<tr valign="top">
|
| 179 |
+
<th scope="row"><?php _e('Password:'); ?> </th>
|
| 180 |
<td><input name="smtp_pass" type="text" id="smtp_pass" value="<?php print(get_option('smtp_pass')); ?>" size="40" class="code" /></td>
|
| 181 |
</tr>
|
| 182 |
</table>
|
|
|
|
| 183 |
|
| 184 |
+
<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options »'); ?>" />
|
| 185 |
<input type="hidden" name="action" value="update" />
|
| 186 |
</p>
|
| 187 |
<input type="hidden" name="page_options" value="<?php print(implode(',',array_keys($wpms_options))); ?>">
|
| 188 |
+
</fieldset>
|
| 189 |
+
</form>
|
| 190 |
+
|
| 191 |
+
<form method="POST">
|
| 192 |
+
<fieldset class="options">
|
| 193 |
+
<legend><?php _e('Send a Test Email'); ?></legend>
|
| 194 |
+
<table class="optiontable">
|
| 195 |
+
<tr valign="top">
|
| 196 |
+
<th scope="row"><?php _e('To:'); ?> </th>
|
| 197 |
+
<td><p><input name="to" type="text" id="to" value="" size="40" class="code" /><br />
|
| 198 |
+
<?php _e('Type an email address here and then click Send Test to generate a test email.'); ?></p></td>
|
| 199 |
+
</tr>
|
| 200 |
+
</table>
|
| 201 |
+
<p class="submit"><input type="submit" name="wpms_action" value="<?php _e('Send Test'); ?>" /></p>
|
| 202 |
+
</fieldset>
|
| 203 |
</form>
|
| 204 |
|
| 205 |
</div>
|
| 233 |
|
| 234 |
/**
|
| 235 |
* //// CHMAC TODO
|
| 236 |
+
* Does this work or does it fail if a name is supplied? Testing required.
|
|
|
|
|
|
|
| 237 |
*/
|
| 238 |
|
| 239 |
// If we can, use the is_email function to verify the email
|
| 242 |
return(get_option('mail_from'));
|
| 243 |
}
|
| 244 |
else {
|
| 245 |
+
return ($orig);
|
| 246 |
}
|
| 247 |
}
|
| 248 |
// If is_email is not available, check there's an @ symbol
|
| 249 |
elseif (strpos(get_option('mail_from'),'@')) {
|
| 250 |
return(get_option('mail_from'));
|
| 251 |
}
|
| 252 |
+
// If there's no is_email and no @, use the supplied variable
|
| 253 |
else {
|
| 254 |
+
return($orig);
|
| 255 |
}
|
| 256 |
|
| 257 |
} // End of wp_mail_smtp_mail_from() function definition
|
