Send email to your Users about new wordpress posts without plugin

For increasing traffic of your wordpress blog or website. It is always good to send email to subscribers about new post.

There are many wordpress plugins available for sending email but I given small code for sending email to wordpress users without using any wordpress pluginss

If you are wordpress developer then only use following code. Open your functions.php file from your theme and put following code in that file. Just copy and paste the following code on your functions.php file:

function send_email_users($post_ID)  {
    global $wpdb;
    $usersarray = $wpdb->get_results("SELECT user_email FROM $wpdb->users;");
    $users = implode(",", $usersarray);
    mail($users, "New Article is Published", 'A new article have been published on http://www.wordpressapi.com. Please visit');
    return $post_ID;
}
add_action('publish_post', 'send_email_users');

You just need to change my domain name to your domain name and put that in your functions.php file. If you are having any issues then Please write to me.
This wordpress hack, tip or trick written by wordpressapi.

Here is some very useful links for wordpress.

Check Following articles for great wordpress hacks of the all the time.

how to create contact us page without wordpress plugin
Add the extra new users details or fields to wordpress without plugin
Display wordpress Tags In A Dropdown Menu without plugin
How to change the Visual Editor Font Size wordpress without plugin
Display wordpress Tags In A Dropdown Menu without plugin
wordpress pagination style without wordpress plugin
show popular posts without wordpress plugin in theme
How to send smtp email through wordpress without plugin
How to put digg button in wordpress without plugin
Get the recent comments without using wordpress plugin or widget
How to Add the social Bookmar Icons in WordPress theme without wordpress plugins
How to exclude pages from wordpress menu without plugin
Show related posts with wordpress post without using any plugin

You may like following Articles!

  • http://www.linktimberland.com timberland

    Hack again?!

  • Pingback: Send email to your Users about new wordpress posts without plugin … | Neorack Tutorials

  • http://sneakernews.blogroo.com/ Clemmie

    greetings, fine website, and a really good understand! just one for my bookmarking.

  • http://www.solarpanelsrevealed.com Solar Panel

    Well can I use a bit of of your post to my blog. I will certainly give a attributable link to wordpressapi.com if i use any info. Tell me if you don’t have any problems with it. Regards :)

    • http://wordpressapi.com Wordpress API

      You can give my post link in your blog or website. Thanks for your comment.

  • Mark Adesina

    Hello,

    Please I need help.

    I get this error while trying to use the code:

    Catchable fatal error: Object of class stdClass could not be converted to string in C:\wamp\www\mark\wp-content\themes\mytheme\functions.php on line 529

    And here is what i have in line 529:
    $users = implode(“,”, $usersarray);

    Please what could be the problem?

    • http://wordpressapi.com Wordpress API

      mail function uses the sendmail mail server. Sendmail can be configured before using this script…this script can be run on linux server. you are using the windows with wamp server.. that’s why you are getting the error. use the linux server for email testing.

      • Petro

        Hi there, I get the same error. My blog is hosted with supremecenter and thus nt on WAMP or LAMP. How can I fix this?

  • http://www.tjana-pengar-pa-internet-tips.com/ Tjäna pengar

    This was exactly what I needed to my new website. My subscribers will be delighted :)

    A big THANK YOU for this useful post !

  • http://blog.tambayanbox.org iskolares

    Thanks for this! I have a slight problem though.

    How do I tweak the code to only send email if a new post is published on one specific category?

    change $post_ID to a constant category ID? thanks!

    • http://wordpressapi.com Wordpress API

      I will reply you soon.

    • Randy

      This is exactly what I was looking for too, but did not see the update posted.
      I am working with another group, and we have Categories set up with a roles plugin so that users can only see particular categories. I want to send email only to those same user that can only that categories, and others that don’t see it, do not get the email. Have you don’t anything like this?

  • http://www.fullonpics.com shashi

    sir
    i want to know that.there is any plugin for email.
    so that a user send there thoughts through email to me directly..
    lets example
    a one user see my web site ..and he/she like it and user want to share or post there story..so he wanted to send me email..if we take normal process .it take long time.
    so i want a email share plugin..just like Facebook
    kindly suggest something