add_action( 'publish_post', 'notify_via_email' );
function notify_via_email( $post_id ) {
$post = get_post( $post_id );
$to = 'example@example.org';

$subject = 'Post Published on ' . get_bloginfo( 'name' );
$message = $post->post_title . ' was published on ' . get_bloginfo( 'name' ) . ' as of ' .  $post->post_date . '. by '.get_the_author_meta('display_name', $post->post_author).' You may view it at ' . get_permalink( $post_id ) . '.';

wp_mail( $to, $subject, $message );
}
Advertisements