i want to send email only new post publish in wordpress admin
when i pulish anything its sending mail to user how to restric this to only new post added to send mail to user
function wpse_19040_notify_admin_on_publish( $new_status, $old_status, $post ) {
if ( $new_status !== 'publish' || $old_status === 'publish' )
return;
if ( ! $post_type = get_post_type_object( $post->post_type ) )
return;
global $wpdb;
$newsletterdata = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."newsletter");
foreach ( $newsletterdata as $newsletteremailall )
{
$newsletteremailall = $newsletteremailall->email;
if(filter_var($newsletteremailall, FILTER_VALIDATE_EMAIL))
{
$subject = $post->post_title;
$message = 'Our new post is here '."\n".'Post Title: ' .$post->post_title. "\n"."click here to visit post: " . get_permalink( $post->ID );
wp_mail( $newsletteremailall, $subject, $message );
}
else
{
}
}
}
add_action( 'transition_post_status', 'wpse_19040_notify_admin_on_publish', 10, 3 );