Check Email - Version 0.5.7

Version Description

Download this release

Release Info

Developer giucu91
Plugin Icon wp plugin Check Email
Version 0.5.7
Comparing to
See all releases

Version 0.5.7

Files changed (3) hide show
  1. check-email.php +215 -0
  2. plugin-register.class.php +86 -0
  3. readme.txt +47 -0
check-email.php ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Check Email
4
+ Plugin URI: http://www.stillbreathing.co.uk/wordpress/check-email/
5
+ Description: Check email allows you to test if your WordPress installation is sending emails correctly.
6
+ Text Domain: check-email
7
+ Version: 0.5.7
8
+ Author: Chris Taylor
9
+ Author URI: http://www.stillbreathing.co.uk
10
+ */
11
+
12
+ // Plugin Register from http://wordpress.org/extend/plugins/plugin-register/
13
+ require_once( "plugin-register.class.php" );
14
+ $register = new Plugin_Register();
15
+ $register->file = __FILE__;
16
+ $register->slug = "checkemail";
17
+ $register->name = "Check Email";
18
+ $register->version = "0.5.7";
19
+ $register->developer = "Chris Taylor";
20
+ $register->homepage = "http://www.stillbreathing.co.uk";
21
+ $register->Register();
22
+
23
+ // add the admin menu option
24
+ add_action( 'admin_menu', 'checkemail_add_admin' );
25
+ function checkemail_add_admin() {
26
+ add_submenu_page( 'tools.php', __("Check Email", "check-email"), __("Check Email", "check-email"), 'edit_users', 'checkemail', 'checkemail' );
27
+ }
28
+
29
+ // add the JavaScript
30
+ add_action( 'admin_head', 'checkemail_add_js' );
31
+ function checkemail_add_js() {
32
+ if ( isset( $_GET["page"] ) && $_GET["page"] == "checkemail" ) {
33
+ echo '
34
+ <script type="text/javascript">
35
+ jQuery(document).ready(function(){
36
+ jQuery(".checkemail-hide").hide();
37
+ jQuery("#checkemail_autoheaders,#checkemail_customheaders").bind("change", function(){
38
+ if (jQuery("#checkemail_autoheaders").is(":checked")){
39
+ jQuery("#customheaders").hide();
40
+ jQuery("#autoheaders").show();
41
+ }
42
+ if (jQuery("#checkemail_customheaders").is(":checked")){
43
+ jQuery("#autoheaders").hide();
44
+ jQuery("#customheaders").show();
45
+ }
46
+ });
47
+ });
48
+ </script>
49
+ ';
50
+ }
51
+ }
52
+ // add the CSS
53
+ add_action( 'admin_head', 'checkemail_add_css' );
54
+ function checkemail_add_css() {
55
+ if ( isset( $_GET["page"] ) && $_GET["page"] == "checkemail" ) {
56
+ echo '
57
+ <style type="text/css">
58
+ #checkemail label {
59
+ width: 16em;
60
+ float: left;
61
+ }
62
+ #checkemail .text {
63
+ width: 30em;
64
+ }
65
+ #checkemail p, #checkemail pre {
66
+ clear: left;
67
+ }
68
+ </style>
69
+ ';
70
+ }
71
+ }
72
+
73
+ // load the check email admin page
74
+ function checkemail() {
75
+ global $current_user;
76
+
77
+ $from_email = apply_filters( 'wp_mail_from', $current_user->user_email );
78
+ $from_name = apply_filters( 'wp_mail_from_name', $from_name );
79
+
80
+ echo '
81
+ <div id="checkemail" class="wrap">
82
+ ';
83
+
84
+ if ( isset( $_POST["checkemail_to"]) && $_POST["checkemail_to"] != "" )
85
+ {
86
+ $nonce = $_REQUEST['_wpnonce'];
87
+ if ( wp_verify_nonce( $nonce, 'checkemail' ) ) {
88
+ $headers = checkemail_send( $_POST["checkemail_to"], $_POST["checkemail_headers"] );
89
+ echo '<div class="updated"><p>' . __( 'The test email has been sent by WordPress. Please note this does NOT mean it has been delivered. See <a href="http://codex.wordpress.org/Function_Reference/wp_mail">wp_mail in the Codex</a> for more information. The headers sent were:', "check-email" ) . '</p><pre>' . str_replace( chr( 10 ), '\n' . "\n", str_replace( chr( 13 ), '\r', $headers ) ) . '</pre></div>';
90
+ } else {
91
+ echo '<div class="updated"><p>' . __( 'Security check failed', "check-email" ) . '</p></div>';
92
+ }
93
+ }
94
+
95
+ echo '
96
+ <h2>' . __( "Check Email" ) . '</h2>
97
+
98
+ <h3>' . __( "Current mail settings", "check-email" ) . '</h3>
99
+ <p>' . __( "SendMail path (UNIX):", "check-email" ) . ' ' . ini_get("sendmail_path") . '</p>
100
+ <p>' . __( "SMTP server (Windows):", "check-email" ) . ' ' . ini_get("SMTP") . '</p>
101
+ <p>' . __( "SMTP port (Windows):", "check-email" ) . ' ' . ini_get("smtp_port") . '</p>
102
+ <p>' . __( "Add X header:", "check-email" ) . ' ' . ini_get("mail.add_x_header") . '</p>
103
+
104
+ <h3>' . __( "Send a test email", "check-email" ) . '</h3>
105
+ <form action="tools.php?page=checkemail" method="post">
106
+ <p><label for="checkemail_to">' . __( "Send test email to:", "check-email" ) . '</label>
107
+ <input type="text" name="checkemail_to" id="checkemail_to" class="text"';
108
+ if ( isset( $_POST["checkemail_to"] ) ) {
109
+ echo ' value="' . esc_attr( $_POST["checkemail_to"] ) . '"';
110
+ }
111
+ echo ' /></p>
112
+ <p><label for="checkemail_autoheaders">' . __( "Use standard headers", "check-email" ) . '</label>
113
+ <input type="radio" id="checkemail_autoheaders" name="checkemail_headers" value="auto"';
114
+ if ( !isset($_POST["checkemail_headers"]) || $_POST["checkemail_headers"] == "auto" ){
115
+ echo ' checked="checked"';
116
+ }
117
+ echo ' /></p>
118
+ <pre id="autoheaders"';
119
+ if ( isset($_POST["checkemail_headers"]) && $_POST["checkemail_headers"] == "custom" ){
120
+ echo ' class="checkemail-hide"';
121
+ }
122
+ echo '>MIME-Version: 1.0
123
+ From: ' . $from_email . '
124
+ Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . '"</pre>
125
+ <p><label for="checkemail_customheaders">' . __( "Use custom headers", "check-email" ) . '</label>
126
+ <input type="radio" id="checkemail_customheaders" name="checkemail_headers" value="custom"';
127
+ if ( isset($_POST["checkemail_headers"]) && $_POST["checkemail_headers"] == "custom" ){
128
+ echo ' checked="checked"';
129
+ }
130
+ echo ' /></p>
131
+ <div id="customheaders"';
132
+ if ( !isset($_POST["checkemail_headers"]) || $_POST["checkemail_headers"] == "auto" ){
133
+ echo ' class="checkemail-hide"';
134
+ }
135
+ echo '>
136
+ <p>' . __( "Set your custom headers below", "check-email" ) . '</p>
137
+ <p><label for="checkemail_mime">' . __( "MIME Version", "check-email" ) . '</label>
138
+ <input type="text" name="checkemail_mime" id="checkemail_mime" value="';
139
+ if ( isset( $_POST["checkemail_mime"] ) ) {
140
+ echo esc_attr( $_POST["checkemail_mime"] );
141
+ } else {
142
+ echo '1.0';
143
+ }
144
+ echo '" /></p>
145
+ <p><label for="checkemail_type">' . __( "Content type", "check-email" ) . '</label>
146
+ <input type="text" name="checkemail_type" id="checkemail_type" value="';
147
+ if ( isset( $_POST["checkemail_type"] ) ) {
148
+ echo esc_attr( $_POST["checkemail_type"] );
149
+ } else {
150
+ echo 'text/html; charset=iso-8859-1';
151
+ }
152
+ echo '" class="text" /></p>
153
+ <p><label for="checkemail_from">' . __( "From", "check-email" ) . '</label>
154
+ <input type="text" name="checkemail_from" id="checkemail_from" value="';
155
+ if ( isset( $_POST["checkemail_from"] ) ) {
156
+ echo esc_attr( $_POST["checkemail_from"] );
157
+ } else {
158
+ echo $from_email;
159
+ }
160
+ echo '" class="text" /></p>
161
+ <p><label for="checkemail_cc">' . __( "CC", "check-email" ) . '</label>
162
+ <textarea name="checkemail_cc" id="checkemail_cc" cols="30" rows="4" class="text">';
163
+ if ( isset( $_POST["checkemail_cc"] ) ) {
164
+ echo esc_textarea( $_POST["checkemail_cc"] );
165
+ }
166
+ echo '</textarea></p>
167
+ <p><label for="checkemail_break_n">' . __( "Header line break type", "check-email" ) . '</label>
168
+ <input type="radio" name="checkemail_break" id="checkemail_break_n" value="\n"';
169
+ if ( !isset( $_POST["checkemail_break"] ) || $_POST["checkemail_break"] == '\n' ) {
170
+ echo ' checked="checked"';
171
+ }
172
+ echo ' /> \n
173
+ <input type="radio" name="checkemail_break" id="checkemail_break_rn" value="\r\n"';
174
+ if ( isset( $_POST["checkemail_break"] ) && $_POST["checkemail_break"] == '\r\n' ) {
175
+ echo ' checked="checked"';
176
+ }
177
+ echo ' /> \r\n</p>
178
+ </div>
179
+ <p><label for="checkemail_go" class="checkemail-hide">' . __( "Send", "check-email" ) . '</label>
180
+ <input type="submit" name="checkemail_go" id="checkemail_go" class="button-primary" value="' . __( "Send test email", "check-email" ) . '" /></p>
181
+ ';
182
+ wp_nonce_field( 'checkemail' );
183
+ echo '</form>
184
+
185
+ </div>
186
+ ';
187
+
188
+ }
189
+
190
+ // send a test email
191
+ function checkemail_send($to, $headers = "auto") {
192
+ global $current_user;
193
+
194
+ $from_email = apply_filters( 'wp_mail_from', $current_user->user_email );
195
+ $from_name = apply_filters( 'wp_mail_from_name', $from_name );
196
+
197
+ if ( $headers == "auto" ) {
198
+ $headers = "MIME-Version: 1.0\r\n" .
199
+ "From: " . $from_email . "\r\n" .
200
+ "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\r\n";
201
+ } else {
202
+ $break = chr( 10 );
203
+ if ( stripslashes( $_POST["checkemail_break"] ) == '\r\n' ) {
204
+ $break = chr( 13 ) . chr( 10 );
205
+ }
206
+ $headers = "MIME-Version: " . trim( $_POST["checkemail_mime"] ) . $break .
207
+ "From: " . trim( $_POST["checkemail_from"] ) . $break .
208
+ "Cc: " . trim( $_POST["checkemail_cc"] ) . $break .
209
+ "Content-Type: " . trim( $_POST["checkemail_type"] ) . $break;
210
+ }
211
+ $title = __( sprintf( "Test email from %s ", get_bloginfo("url") ), "check-email" );
212
+ $body = __( sprintf( 'This test email proves that your WordPress installation at %1$s can send emails.\n\nSent: %2$s', get_bloginfo( "url" ), date( "r" ) ), "check-email" );
213
+ wp_mail( $to, $title, $body, $headers );
214
+ return $headers;
215
+ }
plugin-register.class.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Include this file at the end of your plugin, then create a new instance of the Plugin_Register class. Here's some sample code:
4
+
5
+ // include the Plugin_Register class
6
+ require_once( "plugin-register.class.php" );
7
+
8
+ // create a new instance of the Plugin_Register class
9
+ $register = new Plugin_Register(); // leave this as it is
10
+ $register->file = __FILE__; // leave this as it is
11
+ $register->slug = "pluginregister"; // create a unique slug for your plugin (normally the plugin name in lowercase, with no spaces or special characters works fine)
12
+ $register->name = "Plugin Register"; // the full name of your plugin (this will be displayed in your statistics)
13
+ $register->version = "1.0"; // the version of your plugin (this will be displayed in your statistics)
14
+ $register->developer = "Chris Taylor"; // your name
15
+ $register->homepage = "http://www.stillbreathing.co.uk"; // your Wordpress website where Plugin Register is installed (no trailing slash)
16
+
17
+ // the next two lines are optional
18
+ // 'register_plugin' is the message you want to be displayed when someone has activated this plugin. The %1 is replaced by the correct URL to register the plugin (the %1 MUST be the HREF attribute of an <a> element)
19
+ $register->register_message = 'Hey! Thanks! <a href="%1">Register the plugin here</a>.';
20
+ // 'thanks_message' is the message you want to display after someone has registered your plugin
21
+ $register->thanks_message = "That's great, thanks a million.";
22
+
23
+ $register->Plugin_Register(); // leave this as it is
24
+ */
25
+ if ( !class_exists( "Plugin_Register" ) ) {
26
+ class Plugin_Register {
27
+ var $slug = "";
28
+ var $developer = "the developer";
29
+ var $version = "";
30
+ var $homepage = "#";
31
+ var $name = "";
32
+ var $file = "";
33
+ var $register_message = "";
34
+ var $thanks_message = "";
35
+ function Register() {
36
+ @session_start();
37
+ register_activation_hook( $this->file, array( $this, "Activated" ) );
38
+ add_action( "admin_notices", array( $this, "Registration" ) );
39
+ }
40
+ function Activated() {
41
+ if ( $this->slug != "" && $this->name != "" && $this->version != "" ) {
42
+ $_SESSION["activated_plugin"] = $this->slug;
43
+ }
44
+ }
45
+ function Registration() {
46
+ if ( isset( $_SESSION["activated_plugin"] ) && $_SESSION["activated_plugin"] == $this->slug ) {
47
+ $_SESSION["activated_plugin"] = "";
48
+ echo '
49
+ <div id="message" class="updated fade">
50
+ <p style="line-height:1.4em">
51
+ ';
52
+ if ( $this->register_message == "" || strpos( $this->register_message, "%1" ) === false ) {
53
+ echo '
54
+ <strong>Please consider <a href="plugins.php?paged=' . @$_GET["paged"] . '&amp;' . $this->slug . '=register">registering your use of ' . $this->name . '</a></strong> to tell <a href="' . $this->homepage . '">' . $this->developer . ' (the plugin maker)</a> you are using it. This sends only your site name and URL to ' . $this->developer . ' so they know where their plugin is being used. No other data is sent.';
55
+
56
+ } else {
57
+ echo str_replace( "%1", "plugins.php?paged=" . @$_GET["paged"] . "&amp;" . $this->slug . "=register", $this->register_message );
58
+ }
59
+ echo '
60
+ </p>
61
+ </div>';
62
+ }
63
+ if ( isset( $_GET[$this->slug] ) && $_GET[$this->slug] == "register" ) {
64
+ $site = get_option( "blogname" );
65
+ $url = get_option( "siteurl" );
66
+ $register_url = trim( $this->homepage, "/" ) . "/?plugin=" . urlencode( $this->name ) . "&version=" . urlencode( $this->version ) . "&site=" . urlencode( $site ) . "&url=" . urlencode( $url );
67
+ wp_remote_fopen( $register_url );
68
+ echo '
69
+ <div id="message" class="updated fade">
70
+ <p>';
71
+ if ( $this->thanks_message == "" ) {
72
+ echo '
73
+ <strong>Thank you for registering ' . $this->name . '.</strong>
74
+ ';
75
+ } else {
76
+ echo $this->thanks_message;
77
+ }
78
+ echo '
79
+ </p>
80
+ </div>
81
+ ';
82
+ }
83
+ }
84
+ }
85
+ }
86
+ ?>
readme.txt ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Check Email ===
2
+ Contributors: mrwiblog
3
+ Donate link: http://www.stillbreathing.co.uk/donate/
4
+ Tags: check, test, email, smtp, pop, send, delivery
5
+ Requires at least: 2.7
6
+ Tested up to: 5.3.2
7
+ Stable tag: 0.5.7
8
+
9
+ Check email allows you to test if your WordPress installation is sending emails correctly by sending a test email to an address of your choice. Allows overriding of email headers and carbon copying to another address.
10
+
11
+ == Description ==
12
+
13
+ Don't know if your WordPress installation is sending emails? Use this simple plugin to find out. It will send a simple test email to an email address of your choice, and to help troubleshoot any problems you can also override the custom headers wth your own values.
14
+
15
+ The link to access the tool is in the "Tools" menu.
16
+
17
+ == Installation ==
18
+
19
+ Install the plugin from the plugin repository and activate.
20
+
21
+ == Frequently Asked Questions ==
22
+
23
+ = How do I use it? =
24
+
25
+ The link to access the tool is in the "Tools" menu.
26
+
27
+ = Why did you write this plugin? =
28
+
29
+ Someone using one of my other plugins had trouble with emails not being sent. I knocked this together to help him (and anyone else).
30
+
31
+ == Changelog ==
32
+
33
+ 0.5.7 Added support for the wp_mail_from filter
34
+ 0.5.6 Tested with WordPress 5.1.1
35
+ 0.5.5 Fixed typo (sorry sorry sorry)
36
+ 0.5.4 Added FAQ about the location of the tool in the WordPress admin area
37
+ 0.5.3 Fixed deprecation error messages. Tested with 4.7.2.
38
+ 0.5.2 Fixed un-encoded output related to XSS bug
39
+ 0.5.1 Properly fixed XSS vulnerability (apologies)
40
+ 0.5 Fixed XSS vulnerability found by Antonis Manaras
41
+ 0.4 Added more information from php.ini, fixed incorrect textdomains
42
+ 0.3 Moved the page to the Tools menu
43
+ 0.2 Now displays SMTP server name
44
+ 0.1.3 Fixed version number
45
+ 0.1.2 Fixed bug in Plugin Register caused by latest version of WordPress
46
+ 0.1.1 Fixed typo in plugin name
47
+ 0.1 Initial version