title: wordpress - wp insert post hook for only new posts saved
body: <p>I am using <code>wp insert post</code> as a hook to send an email when ever a new post has been submitted in wordpress, I have taken the reference of this <a href="https://codex.wordpress.org/Plugin_API/Action_Reference/wp_insert_post" rel="nofollow">link</a> and tried below code. I am able to get emails perfectly, the problem is I am receiving mails even when the post is trashed which is not required. Is there any way to trigger mail only when new post is created and not for any other actions.</p>
  
  <pre><code>function my_project_updated_send_email( $post_id, $post, $update ) {
  
  // If this is a revision, don't send the email.
  if ( wp_is_post_revision( $post_id ) )
      return;
  
  $post_url = get_permalink( $post_id );
  $subject = 'A post has been updated';
  
  $message = "A post has been updated on your website:\n\n";
  $message .= $post-&gt;post_title . ": " . $post_url;
  
  // Send email to admin.
  wp_mail( 'admin@example.com', $subject, $message );
  }
  add_action( 'wp_insert_post', 'my_project_updated_send_email', 10, 3 );
  </code></pre>