file = __FILE__; $register->slug = "checkemail"; $register->name = "Check Email"; $register->version = "0.5.7"; $register->developer = "Chris Taylor"; $register->homepage = "http://www.stillbreathing.co.uk"; $register->Register(); // add the admin menu option add_action( 'admin_menu', 'checkemail_add_admin' ); function checkemail_add_admin() { add_submenu_page( 'tools.php', __("Check Email", "check-email"), __("Check Email", "check-email"), 'edit_users', 'checkemail', 'checkemail' ); } // add the JavaScript add_action( 'admin_head', 'checkemail_add_js' ); function checkemail_add_js() { if ( isset( $_GET["page"] ) && $_GET["page"] == "checkemail" ) { echo ' '; } } // add the CSS add_action( 'admin_head', 'checkemail_add_css' ); function checkemail_add_css() { if ( isset( $_GET["page"] ) && $_GET["page"] == "checkemail" ) { echo ' '; } } // load the check email admin page function checkemail() { global $current_user; $from_email = apply_filters( 'wp_mail_from', $current_user->user_email ); $from_name = apply_filters( 'wp_mail_from_name', $from_name ); echo '
'; if ( isset( $_POST["checkemail_to"]) && $_POST["checkemail_to"] != "" ) { $nonce = $_REQUEST['_wpnonce']; if ( wp_verify_nonce( $nonce, 'checkemail' ) ) { $headers = checkemail_send( $_POST["checkemail_to"], $_POST["checkemail_headers"] ); echo '

' . __( 'The test email has been sent by WordPress. Please note this does NOT mean it has been delivered. See wp_mail in the Codex for more information. The headers sent were:', "check-email" ) . '

' . str_replace( chr( 10 ), '\n' . "\n", str_replace( chr( 13 ), '\r', $headers ) ) . '
'; } else { echo '

' . __( 'Security check failed', "check-email" ) . '

'; } } echo '

' . __( "Check Email" ) . '

' . __( "Current mail settings", "check-email" ) . '

' . __( "SendMail path (UNIX):", "check-email" ) . ' ' . ini_get("sendmail_path") . '

' . __( "SMTP server (Windows):", "check-email" ) . ' ' . ini_get("SMTP") . '

' . __( "SMTP port (Windows):", "check-email" ) . ' ' . ini_get("smtp_port") . '

' . __( "Add X header:", "check-email" ) . ' ' . ini_get("mail.add_x_header") . '

' . __( "Send a test email", "check-email" ) . '

MIME-Version: 1.0
From: ' . $from_email . '
Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . '"

' . __( "Set your custom headers below", "check-email" ) . '

\n \r\n

'; wp_nonce_field( 'checkemail' ); echo '
'; } // send a test email function checkemail_send($to, $headers = "auto") { global $current_user; $from_email = apply_filters( 'wp_mail_from', $current_user->user_email ); $from_name = apply_filters( 'wp_mail_from_name', $from_name ); if ( $headers == "auto" ) { $headers = "MIME-Version: 1.0\r\n" . "From: " . $from_email . "\r\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\r\n"; } else { $break = chr( 10 ); if ( stripslashes( $_POST["checkemail_break"] ) == '\r\n' ) { $break = chr( 13 ) . chr( 10 ); } $headers = "MIME-Version: " . trim( $_POST["checkemail_mime"] ) . $break . "From: " . trim( $_POST["checkemail_from"] ) . $break . "Cc: " . trim( $_POST["checkemail_cc"] ) . $break . "Content-Type: " . trim( $_POST["checkemail_type"] ) . $break; } $title = __( sprintf( "Test email from %s ", get_bloginfo("url") ), "check-email" ); $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" ); wp_mail( $to, $title, $body, $headers ); return $headers; }