Easy WP SMTP - Version 1.0.1

Version Description

  • First commit of the plugin
Download this release

Release Info

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

Version 1.0.1

Files changed (3) hide show
  1. easy_wp_smtp.php +65 -0
  2. easy_wp_smtp_admin.php +289 -0
  3. readme.txt +74 -0
easy_wp_smtp.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Easy WP SMTP
4
+ Version: 1.0.1
5
+ Plugin URI: http://wp-ecommerce.net/?p=2197
6
+ Author: wpecommerce
7
+ Author URI: http://wp-ecommerce.net/
8
+ Description: Send email via SMTP from your WordPress Blog
9
+ */
10
+ define('EASY_WP_SMTP_PLUGIN_VERSION', "1.0.1");
11
+ $ewpsOptions = get_option("easy_wp_smtp_options");
12
+
13
+ function easy_wp_smtp($phpmailer){
14
+ global $ewpsOptions;
15
+ if( !is_email($ewpsOptions["from"]) || empty($ewpsOptions["host"]) ){
16
+ return;
17
+ }
18
+ $phpmailer->Mailer = "smtp";
19
+ $phpmailer->From = $ewpsOptions["from"];
20
+ $phpmailer->FromName = $ewpsOptions["fromname"];
21
+ $phpmailer->Sender = $phpmailer->From; //Return-Path
22
+ $phpmailer->AddReplyTo($phpmailer->From,$phpmailer->FromName); //Reply-To
23
+ $phpmailer->Host = $ewpsOptions["host"];
24
+ $phpmailer->SMTPSecure = $ewpsOptions["smtpsecure"];
25
+ $phpmailer->Port = $ewpsOptions["port"];
26
+ $phpmailer->SMTPAuth = ($ewpsOptions["smtpauth"]=="yes") ? TRUE : FALSE;
27
+ if($phpmailer->SMTPAuth){
28
+ $phpmailer->Username = $ewpsOptions["username"];
29
+ $phpmailer->Password = $ewpsOptions["password"];
30
+ }
31
+ $phpmailer->SMTPDebug = 2;
32
+ }
33
+ add_action('phpmailer_init','easy_wp_smtp');
34
+
35
+ function easy_wp_smtp_activate(){
36
+ $ewpsOptions = array();
37
+ $ewpsOptions["from"] = "";
38
+ $ewpsOptions["fromname"] = "";
39
+ $ewpsOptions["host"] = "";
40
+ $ewpsOptions["smtpsecure"] = "";
41
+ $ewpsOptions["port"] = "";
42
+ $ewpsOptions["smtpauth"] = "yes";
43
+ $ewpsOptions["username"] = "";
44
+ $ewpsOptions["password"] = "";
45
+ $ewpsOptions["deactivate"] = "";
46
+ add_option("easy_wp_smtp_options",$ewpsOptions);
47
+ }
48
+ register_activation_hook( __FILE__ , 'easy_wp_smtp_activate' );
49
+
50
+ if($ewpsOptions["deactivate"]=="yes"){
51
+ register_deactivation_hook( __FILE__ , create_function('','delete_option("easy_wp_smtp_options");') );
52
+ }
53
+
54
+ function easy_wp_smtp_settings_link($action_links,$plugin_file){
55
+ if($plugin_file==plugin_basename(__FILE__)){
56
+ $ewps_settings_link = '<a href="options-general.php?page=' . dirname(plugin_basename(__FILE__)) . '/easy_wp_smtp_admin.php">' . __("Settings") . '</a>';
57
+ array_unshift($action_links,$ewps_settings_link);
58
+ }
59
+ return $action_links;
60
+ }
61
+ add_filter('plugin_action_links','easy_wp_smtp_settings_link',10,2);
62
+
63
+ if(is_admin()){require_once('easy_wp_smtp_admin.php');}
64
+
65
+ ?>
easy_wp_smtp_admin.php ADDED
@@ -0,0 +1,289 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function easy_wp_smtp_admin(){
3
+ add_options_page('Easy WP SMTP Options', 'Easy WP SMTP','manage_options', __FILE__, 'easy_wp_smtp_options_page');
4
+ }
5
+
6
+ function easy_wp_smtp_options_page()
7
+ {
8
+ global $ewpsOptions, $phpmailer;
9
+ $smtp_debug = "";
10
+ $exceptionmsg = "";
11
+ $full_debug = false;
12
+ if(isset($_POST['easy_wp_smtp_update']))
13
+ {
14
+ $ewpsOptions = array();
15
+ $ewpsOptions["from"] = trim($_POST['easy_wp_smtp_from']);
16
+ $ewpsOptions["fromname"] = trim($_POST['easy_wp_smtp_fromname']);
17
+ $ewpsOptions["host"] = trim($_POST['easy_wp_smtp_host']);
18
+ $ewpsOptions["smtpsecure"] = trim($_POST['easy_wp_smtp_smtpsecure']);
19
+ $ewpsOptions["port"] = trim($_POST['easy_wp_smtp_port']);
20
+ $ewpsOptions["smtpauth"] = trim($_POST['easy_wp_smtp_smtpauth']);
21
+ $ewpsOptions["username"] = trim($_POST['easy_wp_smtp_username']);
22
+ $ewpsOptions["password"] = trim($_POST['easy_wp_smtp_password']);
23
+ $ewpsOptions["deactivate"] = (isset($_POST['easy_wp_smtp_deactivate'])) ? trim($_POST['easy_wp_smtp_deactivate']) : "";
24
+ update_option("easy_wp_smtp_options",$ewpsOptions);
25
+ if(!is_email($ewpsOptions["from"])){
26
+ echo '<div id="message" class="updated fade"><p><strong>From</strong> field must contain a valid email address</p></div>';
27
+ }
28
+ elseif(empty($ewpsOptions["host"])){
29
+ echo '<div id="message" class="updated fade"><p><strong>Host</strong> field cannot be left empty</p></div>';
30
+ }
31
+ else{
32
+ echo '<div id="message" class="updated fade"><p>Options saved</p></div>';
33
+ }
34
+ }
35
+ if(isset($_POST['easy_wp_smtp_test']))
36
+ {
37
+ $to = trim($_POST['easy_wp_smtp_to']);
38
+ $subject = trim($_POST['easy_wp_smtp_subject']);
39
+ $message = trim($_POST['easy_wp_smtp_message']);
40
+ $failed = 0;
41
+ $empty_fields = false;
42
+ if(empty($to) || empty($subject) || empty($message))
43
+ {
44
+ echo '<div id="message" class="updated fade"><p>You must fill in the <strong>To</strong>, <strong>Subject</strong> and <strong>Message</strong> fields to send a test email</p></div>';
45
+ $empty_fields = true;
46
+ }
47
+ if(!$empty_fields)
48
+ {
49
+ $full_debug = true;
50
+ ob_start();
51
+ try
52
+ {
53
+ $result = wp_mail($to,$subject,$message);
54
+ }
55
+ catch(phpmailerException $e)
56
+ {
57
+ $failed = 1;
58
+ $exceptionmsg = $e->errorMessage();
59
+ }
60
+ $smtp_debug = ob_get_clean();
61
+ if(!empty($exceptionmsg))
62
+ {
63
+ echo '<div id="message" class="updated fade"><p>Exception thrown: '.$exceptionmsg.'</p></div>';
64
+ }
65
+ if(!$failed)
66
+ {
67
+ if($result==TRUE)
68
+ {
69
+ echo '<div id="message" class="updated fade"><p>Email sent</p></div>';
70
+ }
71
+ else
72
+ {
73
+ echo '<div id="message" class="updated fade"><p>Email could no be sent</p></div>';
74
+ }
75
+ }
76
+ }
77
+ }
78
+ ?>
79
+ <div class="wrap">
80
+ <?php screen_icon(); ?>
81
+ <h2>
82
+ Easy WP SMTP v<?php echo EASY_WP_SMTP_PLUGIN_VERSION; ?>
83
+ </h2>
84
+ <div id="poststuff"><div id="post-body">
85
+ <div class="postbox">
86
+ <h3><label for="title">General Settings</label></h3>
87
+ <div class="inside">
88
+ <form action="" method="post" enctype="multipart/form-data" name="easy_wp_smtp_form">
89
+ <p>Please check the <a href="http://wp-ecommerce.net/?p=2197" target="_blank">documentation</a> before you configure the general settings</p>
90
+ <table class="form-table">
91
+ <tr valign="top">
92
+ <th scope="row">
93
+ From Email Address
94
+ </th>
95
+ <td>
96
+ <label>
97
+ <input type="text" name="easy_wp_smtp_from" value="<?php echo $ewpsOptions["from"]; ?>" size="43" />
98
+ </label>
99
+ <p>The email address that will be used to send emails to your recipients</p>
100
+ </td>
101
+ </tr>
102
+ <tr valign="top">
103
+ <th scope="row">
104
+ From Name
105
+ </th>
106
+ <td>
107
+ <label>
108
+ <input type="text" name="easy_wp_smtp_fromname" value="<?php echo $ewpsOptions["fromname"]; ?>" size="43" />
109
+ </label>
110
+ <p>The name your recipients will see as part of the "from" or "sender" value when they receive your message</p>
111
+ </td>
112
+ </tr>
113
+ <tr valign="top">
114
+ <th scope="row">
115
+ SMTP Host
116
+ </th>
117
+ <td>
118
+ <label>
119
+ <input type="text" name="easy_wp_smtp_host" value="<?php echo $ewpsOptions["host"]; ?>" size="43" />
120
+ </label>
121
+ <p>Your outgoing mail server (example: smtp.gmail.com)</p>
122
+ </td>
123
+ </tr>
124
+ <tr valign="top">
125
+ <th scope="row">
126
+ Type of Encryption
127
+ </th>
128
+ <td>
129
+ <label>
130
+ <input name="easy_wp_smtp_smtpsecure" type="radio" value=""<?php if ($ewpsOptions["smtpsecure"] == '') { ?> checked="checked"<?php } ?> />
131
+ None
132
+ </label>
133
+ &nbsp;
134
+ <label>
135
+ <input name="easy_wp_smtp_smtpsecure" type="radio" value="ssl"<?php if ($ewpsOptions["smtpsecure"] == 'ssl') { ?> checked="checked"<?php } ?> />
136
+ SSL
137
+ </label>
138
+ &nbsp;
139
+ <label>
140
+ <input name="easy_wp_smtp_smtpsecure" type="radio" value="tls"<?php if ($ewpsOptions["smtpsecure"] == 'tls') { ?> checked="checked"<?php } ?> />
141
+ TLS
142
+ </label>
143
+ <p>For most servers SSL is the recommended option</p>
144
+ </td>
145
+ </tr>
146
+ <tr valign="top">
147
+ <th scope="row">
148
+ SMTP Port
149
+ </th>
150
+ <td>
151
+ <label>
152
+ <input type="text" name="easy_wp_smtp_port" value="<?php echo $ewpsOptions["port"]; ?>" size="43" />
153
+ </label>
154
+ <p>The port that will be used to relay outbound mail to your mail server (example: 465)</p>
155
+ </td>
156
+ </tr>
157
+ <tr valign="top">
158
+ <th scope="row">
159
+ SMTP Authentication
160
+ </th>
161
+ <td>
162
+ <label>
163
+ <input name="easy_wp_smtp_smtpauth" type="radio" value="no"<?php if ($ewpsOptions["smtpauth"] == 'no') { ?> checked="checked"<?php } ?> />
164
+ No
165
+ </label>
166
+ &nbsp;
167
+ <label>
168
+ <input name="easy_wp_smtp_smtpauth" type="radio" value="yes"<?php if ($ewpsOptions["smtpauth"] == 'yes') { ?> checked="checked"<?php } ?> />
169
+ Yes
170
+ </label>
171
+ <p>This option should always be checked "Yes".</p>
172
+ </td>
173
+ </tr>
174
+ <tr valign="top">
175
+ <th scope="row">
176
+ Username
177
+ </th>
178
+ <td>
179
+ <label>
180
+ <input type="text" name="easy_wp_smtp_username" value="<?php echo $ewpsOptions["username"]; ?>" size="43" />
181
+ </label>
182
+ <p>The username that you use to login to your mail server (example: abc123@gmail.com)</p>
183
+ </td>
184
+ </tr>
185
+ <tr valign="top">
186
+ <th scope="row">
187
+ Password
188
+ </th>
189
+ <td>
190
+ <label>
191
+ <input type="password" name="easy_wp_smtp_password" value="<?php echo $ewpsOptions["password"]; ?>" size="43" />
192
+ </label>
193
+ <p>The password that you use to login to your mail server</p>
194
+ </td>
195
+ </tr>
196
+ <!--
197
+ <tr valign="top">
198
+ <th scope="row">
199
+ Delete Options
200
+ </th>
201
+ <td>
202
+ <label>
203
+ <input type="checkbox" name="easy_wp_smtp_deactivate" value="yes" <?php if($ewpsOptions["deactivate"]=='yes') echo 'checked="checked"'; ?> />
204
+ Automatically Delete options when you deactivate the plugin
205
+ </label>
206
+ </td>
207
+ </tr>
208
+ -->
209
+ </table>
210
+
211
+ <p class="submit">
212
+ <input type="hidden" name="easy_wp_smtp_update" value="update" />
213
+ <input type="submit" class="button-primary" name="Submit" value="<?php _e('Save Changes'); ?>" />
214
+ </p>
215
+
216
+ </form>
217
+ </div></div>
218
+
219
+ <div class="postbox">
220
+ <h3><label for="title">Testing & Debugging Settings</label></h3>
221
+ <div class="inside">
222
+ <form action="" method="post" enctype="multipart/form-data" name="wp_smtp_testform">
223
+ <table class="form-table">
224
+ <tr valign="top">
225
+ <th scope="row">
226
+ To:
227
+ </th>
228
+ <td>
229
+ <label>
230
+ <input type="text" name="easy_wp_smtp_to" value="" size="43" />
231
+ </label>
232
+ <p>Enter the email address of the recipient </p>
233
+ </td>
234
+ </tr>
235
+ <tr valign="top">
236
+ <th scope="row">
237
+ Subject:
238
+ </th>
239
+ <td>
240
+ <label>
241
+ <input type="text" name="easy_wp_smtp_subject" value="" size="43" />
242
+ </label>
243
+ <p>Enter a subject for your message</p>
244
+ </td>
245
+ </tr>
246
+ <tr valign="top">
247
+ <th scope="row">
248
+ Message:
249
+ </th>
250
+ <td>
251
+ <label>
252
+ <textarea type="text" name="easy_wp_smtp_message" value="" cols="45" rows="5"></textarea>
253
+ </label>
254
+ <p>Write your message</p>
255
+ </td>
256
+ </tr>
257
+ </table>
258
+ <p class="submit">
259
+ <input type="hidden" name="easy_wp_smtp_test" value="test" />
260
+ <input type="submit" class="button-primary" value="Send Test Email" />
261
+ </p>
262
+ </form>
263
+ </div></div>
264
+ <?php
265
+ if(!empty($smtp_debug))
266
+ {
267
+ ?>
268
+ SMTP Debug:
269
+ <p>
270
+ <textarea type="text" cols="50" rows="20"><?php echo $smtp_debug;?></textarea>
271
+ </p>
272
+ <?php
273
+ }
274
+ if($full_debug)
275
+ {
276
+ ?>
277
+ Full Debug:
278
+ <p>
279
+ <textarea type="text" cols="50" rows="20"><?php var_dump($phpmailer);?></textarea>
280
+ </p>
281
+ <?php
282
+ }
283
+ ?>
284
+ </div></div>
285
+ </div>
286
+ <?php
287
+ }
288
+ add_action('admin_menu', 'easy_wp_smtp_admin');
289
+ ?>
readme.txt ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Easy WP SMTP ===
2
+ Contributors: wpecommerce
3
+ Donate link: http://wp-ecommerce.net/?p=2197
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: 3.0
6
+ Tested up to: 3.5.1
7
+ Stable tag: 1.0.1
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Easily send emails from your WordPress blog using your preferred SMTP server
12
+
13
+ == Description ==
14
+
15
+ Easy WP SMTP allows you to configure and send all outgoing emails via a SMTP server. This will prevent your emails from going into the junk/spam folder of the recipients.
16
+
17
+ = Easy WP SMTP Features =
18
+
19
+ * Send email using a SMTP sever.
20
+ * You can use Gmail, Yahoo, Hotmail's SMTP server if you have an account with them.
21
+ * Seamlessly connect your WordPress blog with a mail server to handle all outgoing emails (it's as if the email has been composed inside your mail account).
22
+ * Securely deliver emails to your recipients.
23
+
24
+ = Easy WP SMTP Plugin Usage =
25
+
26
+ Once you have installed the plugin there are some options that you need to configure in the plugin setttings (go to `Settings->Easy WP SMTP` from your WordPress Dashboard).
27
+
28
+ **a)** Easy WP SMTP General Settings
29
+
30
+ The general settings section consists of the following options
31
+
32
+ * From Email Address: The email address that will be used to send emails to your recipients
33
+ * From Name: The name your recipients will see as part of the "from" or "sender" value when they receive your message
34
+ * SMTP Host: Your outgoing mail server (example: smtp.gmail.com)
35
+ * Type of Encryption: none/SSL/TLS
36
+ * SMTP Port: The port that will be used to relay outbound mail to your mail server (example: 465)
37
+ * SMTP Authentication: No/Yes (This option should always be checked "Yes")
38
+ * Username: The username that you use to login to your mail server
39
+ * Password: The password that you use to login to your mail server
40
+
41
+ For detailed documentation on how you can configure these options please visit the [Easy WordPress SMTP](http://wp-ecommerce.net/easy-wordpress-smtp-send-emails-from-your-wordpress-site-using-a-smtp-server-2197) plugin page
42
+
43
+ **b)** Easy WP SMTP Testing & Debugging Settings
44
+
45
+ This section allows you to perform some email testing to make sure that your WordPress site is ready to relay all outgoing emails to your configured SMTP server. It consists of the following options:
46
+
47
+ * To: The email address that will be used to send emails to your recipients
48
+ * Subject: The subject of your message
49
+ * Message: A textarea to write your test message.
50
+
51
+ Once you click the "Send Test Email" button the plugin will try to send an email to the recipient specified in the "To" field.
52
+
53
+ == Installation ==
54
+
55
+ 1. Go to the Add New plugins screen in your WordPress admin area
56
+ 1. Click the upload tab
57
+ 1. Browse for the plugin file (easy-wp-smtp.zip)
58
+ 1. Click Install Now and then activate the plugin
59
+ 1. Now, go to the settings menu of the plugin and follow the instructions
60
+
61
+ == Frequently Asked Questions ==
62
+
63
+ = Can this plugin be used to send emails via SMTP? =
64
+
65
+ Yes.
66
+
67
+ == Screenshots ==
68
+
69
+ For screenshots please visit the [Easy WordPress SMTP](http://wp-ecommerce.net/easy-wordpress-smtp-send-emails-from-your-wordpress-site-using-a-smtp-server-2197) plugin page
70
+
71
+ == Changelog ==
72
+
73
+ = 1.0.1 =
74
+ * First commit of the plugin