hooks – I would like to send an email whenever something is published in the website (posts, pages, custom post types)

The code below works perfectly

When I create a new post, an email is sent out to the email included in the function.

I would like to know how I can send an email when anything is published on the website, like custom post types, pages and regular posts

function notifyauthor($post_id) {
 
$post = get_post($post_id);
$author = get_userdata($post->post_author);
$subject = "Post Published: ".$post->post_title."";
 
$message = "
      Hi ".$author->display_name.",
       
      Your post, "".$post->post_title."" has just been published.
       
      View post: ".get_permalink( $post_id )."
       
      Thanks"
      ;
       
   wp_mail("myemail@abcd.com", $subject, $message);
}
add_action('publish_post', 'notifyauthor');