Getting page / post URL on publish and / or update

A simple solution for you – this hook will send you a full URL to the post that is being published. Don’t forget to update [email protected]

function post_published_notification( $ID, $post ) {
    $permalink = get_permalink( $ID ); // GETTING THE PERMALINK
    $to[] = '[email protected]'; // UPDATE THIS

    $title = $post->post_title;
    $subject = sprintf( 'Published: %s', $title );
    $message = sprintf( 'View: %s', $permalink );
    wp_mail( $to, $subject, $message, [] );
}
add_action( 'publish_post', 'post_published_notification', 10, 2 );

If you want it to work on post update as well, just add this action to the bottom of it:

add_action( 'save_post', 'post_published_notification', 10, 2 );

You can add this hooks to the bottom of your functions.php or in your plugin.