-
-
Save bahiirwa/bc412582efa708528f9c563031fff031 to your computer and use it in GitHub Desktop.
WordPress Emails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function set_mail_html_content_type() { | |
return 'text/html'; | |
} | |
add_action( 'publish_post', 'author_publish_notice', 10 ,2 ); | |
function author_publish_notice( $ID, $post ) { | |
if( 'post' == $post->post_type ) { | |
return; | |
} | |
$to = 'author@email.com'; | |
$subject = 'Your Article Is Online'; | |
$message = '<h1>Congratulations!</h1> <p>Your article is now online and | |
is sure to receives trillions of comments. Please do hang around and answer any questions | |
viewers may have!</p> <p><a href="' . get_permalink( $ID ) . '">' . $post->post_title . '</a></p>'; | |
add_filter( 'wp_mail_content_type', 'set_mail_html_content_type' ); | |
wp_mail( $to, $subject, $message ); | |
remove_filter( 'wp_mail_content_type', 'set_mail_html_content_type' ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$to = 'my@email.com'; | |
$subject = 'Welcome To The Tutorial'; | |
$message = 'Hello! I hope you are enjoying this article, it is great to see you!'; | |
wp_mail( $to, $subject, $message ); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function set_mail_html_content_type() { | |
return 'text/html'; | |
} | |
$to = 'my@email.com'; | |
$subject = 'Welcome To The Tutorial'; | |
$message = '<h1>Hello!</h1> <p>I hope you are enjoying this article, it is great to see you!</p>'; | |
add_filter( 'wp_mail_content_type', 'set_mail_html_content_type' ); | |
wp_mail( $to, $subject, $message ); | |
remove_filter( 'wp_mail_content_type', 'set_mail_html_content_type' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php wp_mail( $to, $subject, $message, $headers, $attachments ); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment