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.
If you liked this article, you may also like:


{ 1 comment… read it below or add one }
I didn’t realise creating a WP plugin was so easy if I knew a little PHP. Back into the books.