<?php
/*
Plugin Name: Draft Notification
Plugin URI: http://www.dagondesign.com/articles/draft-notification-plugin-for-wordpress/
Description: Sends an email to the site admin when a draft is saved.
Author: Aleister
Version: 1.0
Author URI: http://www.dagondesign.com
*/


function dddn_process($id) {

    global 
$wpdb$table_prefix;

    
$result $wpdb->get_row("
        SELECT post_status, post_title, post_author 
        FROM {$table_prefix}posts
        WHERE ID = '$id'
    "
);

    if (
$result->post_status == "draft") {

        
$message "";
        
$message .= "A draft was updated on '" get_bloginfo('name') . "'\n\n";
        
$message .= "Title: " $result->post_title "\n\n";
        
$message .= "Author: " $result->post_author "\n\n";
        
$message .= "Link: " get_permalink($id);

        
$subject "Draft Updated on '" get_bloginfo('name') . "\'";

        
$recipient get_bloginfo('admin_email');

        
mail($recipient$subject$message"From: " get_settings('admin_email') . "\r\nReply-To: " get_settings('admin_email') . "\r\nErrors-to: " get_settings('admin_email') . "\r\nX-Mailer: PHP/" phpversion() . "\r\nPrecedence: Bulk\r\nAuto-Submitted: auto-generated\r\n");

    }

}


add_action('save_post''dddn_process');

?>