Short WP New Post Email Notification List

There are quite a few plugins that add mailing list functionality to your blog, meaning that users can subscribe to mailing lists, new posts or new comment notifications – and so on. A problem arose when I decided that I wanted to add a notification system to a new blog (having never used such a system before), but I wanted to integrate subscriptions via a third party email management application that I use for, well, at least a few hundred different lists. I didn’t want to have to have a new list integrated within WordPress.

Here’s a quick function that will notify a short list of people when you publish a post – good if you just want to email out a small group of authors. You can download the very lightweight code below and upload it to plugins directory (after editing required fields), then activate as per usual.

function email_list($post_ID)  {
   $friends = 'user1@domain.com, user2@domain.net, user3@domain.org';
   $headers = 'From: YourNameHere ' . "\r\n\\";
   mail($friends, "My Blog is Updated" , 'New post published on my blog: http://www.My-Domain-Name.com', $headers);
   return $post_ID;
}
add_action('publish_post', 'email_list');

I built upon this basic code and simply query a third party database, import the address and relevant data into an array, and then use a similar function as I have published above to send the mail (using the SMTP plugin WP SMTP Mail). By integrating, I can retain full functionality offered by my commericial mail software such as open rates, open times, bounce rates and so on – and I don’t have to manage fractionalised marketing data.

I’ll test it for a few weeks and – if all goes to plan – I will make the code available on this site as a downloadable plugin for use with a popular open source mail platform that many people use.


Download: Email Post Notification
Description: WordPress Email Post Notification.
Author:Marty

Date: June 25, 2010

If you liked this article, you may also like:

  1. A problem with the PHP mail function… and alternatives
  2. Email subscription form in your RSS feed?
  3. My take on Short URL Services – Protect Your Brand!
  4. [Shortcode] Easily post an aviation Metar report into your post or page with shortcode
  5. WordPress plugin Evil
About Marty

is a passionate web developer from Sydney, Australia. He owns about 400 websites and makes a healthy living from working the web. As a day job, he works as a pilot for an international airline. You can follow Marty on Twitter or Google+.

Comments

  1. Neazy says:

    I didn’t realise creating a WP plugin was so easy if I knew a little PHP. Back into the books.

Speak Your Mind

*