Email Send on Post Generating – WordPress

<?php

/*

 * Plugin Name:       Email Send On Post

 * Plugin URI:        https://observerinsider.wordpress.com

 * Description:       Recieve email on generating post.

 * Version:           1.1.0

 * Requires at least: 5.2

 * Requires PHP:      7.2

 * Author:            Ahsan Saeed

 * Author URI:        https://observerinsider.wordpress.com

 * License:          

 * License URI:       https://observerinsider.wordpress.com

 * Update URI:        https://observerinsider.wordpress.com

 * Text Domain:      

 * Domain Path:      

 */

function wpacademy_publish_send_mail(){

    global $post;

    $author = $post->post_author;

    $name = get_the_author_meta(‘display_name’,$author);

    $email = get_the_author_meta(‘user_email’,$author);

    $title = $post->post_title;

    $permalink = get_permalink ($ID);

    $to[] = sprintf(‘%s <%s>’, $name,$email);

    $subject = sprintf(‘Published: %s’,$title);

    $message  = sprintf(‘Congrats’);

    $message.=sprintf(‘View : %s’, $permalink);

    $headers[] =”;

    wp_mail($to,$subject,$message, $headers);

}

add_action(‘publish_post’,’wpacademy_publish_send_mail’);

?>

One thought on “Email Send on Post Generating – WordPress

Leave a comment