post Category: Techie — Gudlyf @ 2:16 pm — post Comments (56)

I threw together a quick plugin for the new WordPress 1.2 that will email addresses when the site has a new or updated entry. I’ve put the newest version of this plugin here rather than pasting the whole thing in this post (and messing up formatting).

(I also recently found this site which has some hacks available for subscription lists)

Be sure to put this file in wp-content/plugins as update-notify.php

Latest version: 1.2

Changes since 1.1:

  • Only those posts that are ‘published’ will send mail (i.e., if you simply save the post when editing, it will not mail out to the list). Thanks to the edits listed in the new Subscriber plugin, which you may or may not like better than this one.

Changes since 1.0:

  • Only emails on new and published posts (i.e., no drafts or private posts)

Changes since 0.3:

    n now easily update the email list by instead creating a private post as the admin user (user ID#1) with a title of “updatenotify-list”. Each address must be on a seperate line.

  • Added a permalink to the post in the email body.

Check this link in the future for updates (if I make any).

Horaayy..there are 56 comment(s) for me so far ;)

#1

[...] poster) to see how what they write will look like as they type. Keith McDuffee’s Update Notify that sends an email to when a new post is made. The pl [...]

#2

Great!
Please include in future version a configurable SMTP options (server, account, etc.)

Anonymous wrote on May 25, 2004 - 1:17 am
#3

I guess if you really needed full mailing functionality, you could install PHP Mailer and edit the Update Notify script accordingly. Maybe I’ll make some changes to the script to allow use of this package.

Gudlyf wrote on May 25, 2004 - 8:12 am
#4

WP Plugin: Update Notify
I found here a WP Plugin that will notify an array of e-mail addresses whenever you post a new entry to your blog. This is bare bones as you have to hard code the e-mail addresses into the plugin.

Blogging Pro – Blog News, Tools and Hacks wrote on May 27, 2004 - 6:29 pm
#5

I don’t understand why it’s not working. I enabled the plugin and made a private post from the administrator with some e-mail addresses in it separated by carriage returns. When I post, nothing happens.

Maybe I need to call the function somewhere, but I can’t figure out where to put it so it doesn’t cause an error message. What specifically do I need to add and where do I put it? Thanks.

Victor Van Hee wrote on May 30, 2004 - 3:30 am
#6

You don’t need to add it anywhere — it should just work. It’s possible your web server isn’t allowing the mail() function to work…? Also, is your administrator account listed in the database as user ID #1?

Gudlyf wrote on May 30, 2004 - 8:59 am
#7

hmmm weird. maybe the mail fnctn isn’t working, but it’s strange that I’m getting comments e-mailed to me okay. Yep, it’s user ID #1… i’ll have to work on this.

Victor Van Hee wrote on May 30, 2004 - 7:31 pm
#8

<?php
mail(”me@mydomain.com”, “My Subject”, “Hi\nDoes this work\nI dont know”);
?>

nope, the above script works to mail me something…. interesting…

Victor Van Hee wrote on May 30, 2004 - 7:43 pm
#9

Boy do I feel stupid. I forgot to title the post “updatenotify-list”. It works!!! Thanks.

Victor Van Hee wrote on May 30, 2004 - 7:54 pm
#10

Can someone please elaborate on the installation of this script? My webhosting service doesn’t give shell access, so they use some auto installer for WordPress and I don’t have a plugins or wp-content directory. Do I have to create these or should the install do it for me? Do I have to “enable” the script? Thanks.

Mk wrote on June 1, 2004 - 5:12 pm
#11

Unfortunately you’ll need shell or ftp access to install the plugin. Once it’s in your wp-content/plugins directory, you’ll be able to enable it. The wp-content directory should be in the same place your wp-admin directory is.

Gudlyf wrote on June 1, 2004 - 9:51 pm
#12

Is there any way to change it so it only sends emails on new posts, no updated ones?

chutney wrote on June 4, 2004 - 8:56 am
#13

Not at the moment, no. I’ll have to consider where that would be an option, though (if people will have to edit the plugin themselves or what).

Gudlyf wrote on June 4, 2004 - 9:08 am
#14

You can pull the email addresses from the registered blog users rather than a seperate post if you want with this code:

if (0) {
if ( $email_list = $wpdb->get_results("
SELECT post_content
FROM $tableposts
WHERE post_title = '$settingpost'
AND post_status = 'private'
AND post_author = 1
LIMIT 1
", ARRAY_A) ) {
$recipients = array();
foreach ($email_list as $email) {
$recipients = split("[\n\r]",$email['post_content']);
}
}
}
$recipients = array();
$emails = $wpdb->get_results("SELECT ID from $tableusers WHERE user_email !=''");
foreach ($emails as $email) {
$user_data = get_userdata($email->ID);
$recipients = $user_data->user_email;
}

Dan wrote on June 20, 2004 - 9:44 am
#15

that code is not quite right, and can be simplified. Make sure you add global $tableusers !!

instead of:
----
$recipients = array();
$emails = $wpdb->get_results("SELECT ID from $tableusers WHERE user_email !=''");
foreach ($emails as $email) {
$user_data = get_userdata($email->ID);
$recipients = $user_data->user_email;
}
----

put
----
$emails = $wpdb->get_results("SELECT user_email from $tableusers WHERE user_email !=''");
foreach ($emails as $email) {
$recipients[] = $email->user_email;
}
----

Dan wrote on June 20, 2004 - 1:13 pm
#16

Thanks for this plugin. Just installed it, works great, except that I had to change one variable to correct an error in the URL given inside the generated email if the blog’s path differs from the WP path:
line 41 change “get_settings(’siteurl’)” to “get_settings(’home’)”

fz @ serendipity wrote on July 10, 2004 - 8:40 pm
#18

Hi — I just downloaded and installed your plug-in. It only took a couple of minutes, and it works flawlessly! Thanks for writing the plug-in and making it available. I really appreciate it.

Fred Lane wrote on August 10, 2004 - 12:23 am
#19

The plugin works great except for when in combination with John Blade’s wp-mail mod. I’m not sure why but it doesn’t work when you email in a post. Posting through the admin web interface works great though. If you ahve any help with this, I’d appreciate it. I’ve gone through it a few times and can’t find where the problem is.

Thanks

nate wrote on September 3, 2004 - 8:11 pm
#20

Actually, to update my last post. It doesn’t work with the default WP Post by Email feature either. If I find a solution, I’ll post it.

nate wrote on September 3, 2004 - 8:34 pm
#21

Sorry for offtopic… Could you please tell what plugin do you use con generate those images with the “code” to enter to approve a “humanity” of the commenter?

aim wrote on September 26, 2004 - 6:44 am
#22

Напоминалка о комментах
Поставил простейшую напоминалку. Теперь если пользователь оставит свой email в поле комментария и если к посту сделают ещё комментарий, то …

aim’s blog wrote on September 26, 2004 - 9:55 am
#23

Thanks for the code! I made a couple of modifications. The first one is, if there are more than one updatenotify-list posts in existence, I use the most recent one to figure out who to send to (which I think is the semantcis that makes sense). Also, I changed things so that it sends the body of the post in the email message (preserving the HTML formatting).

I’m going to try to cut-and-paste the code in for you, but if it doesn’t work well, feel free to email me and I’ll send you the changes. (This is my first ever PHP code, and the first time I’ve mucked with WordPress, so I may have done something bone-headed.) My email address is my last name at maya . com.


< ?php
/*
Plugin Name: Update Notify
Plugin URI: http://www.gudlyf.com/index.php?p=357
Description: Notifies an email list of the site having updated or new entries. Put email list in a PRIVATE post titled 'updatenotify-list' created by the ADMIN (user id#1). Put each email on a seperate line.
Version: 1.2
Author: Keith McDuffee
Author URI:
http://www.gudlyf.com/
*/

/*
Keith's code didn't include the post body in the message, so I fixed that.
If there are multiple updatenotify-list entries, now it uses the most
recent.

-higgins@maya.com
*/

function update_notify() {

global $post_ID, $wpdb;
global $tableposts;

/* This is the post title that's checked for the email list */
$settingpost = "updatenotify-list";

/* Get the email list. Only allow the list that's posted
by the admin and that's marked private
*/
if ( $email_list = $wpdb->get_results("
SELECT post_content
FROM $tableposts
WHERE post_title = '$settingpost'
AND post_status = 'private'
AND post_author = 1
ORDER BY post_date
DESC
LIMIT 1
", ARRAY_A) ) {
$recipients = array();
foreach ($email_list as $email) {
$recipients = split("[\n\r]",$email['post_content']);
}
}

$subject = get_settings('blogname') . " has been updated!";
$name = get_settings('blogname');
$sender = get_settings("admin_email");

$text = $text . "Read the post here.\n\n";
$post_text = $wpdb->get_var("SELECT post_content FROM $tableposts WHERE 1=1 ORDER BY post_date DESC LIMIT 1");
$text = $text . $post_text;

/*
$text = $text . get_settings('blogname') . " has a new or updated entry. Be sure to check";
$text = $text . " the site at " . get_settings('siteurl');
$text = $text . " (or directly to the post at " . get_permalink($post_ID) . ")";
*/

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

if (isset($_POST['publish'])) {
foreach($recipients as $recipient) {
if(!empty($recipient)) {
mail($recipient,$subject,$text,"From: $name < $sender>\r\n" . $headers);
}
}
}
}

add_action('publish_post', 'update_notify',8);

?>

Michael Higgins wrote on October 13, 2004 - 5:55 pm
#24

I’ve installed this and it notifies me of updates, but when I click write I then get a blank page with the following error

Warning: Cannot modify header information – headers already sent by (output started at /home/otorna/public_html/updates/wp-content/plugins/update-notify.php:57) in /home/otorna/public_html/updates/wp-admin/post.php on line 146

Any help appreciate.

Thanks
Ambrose

Ambrose wrote on October 17, 2004 - 2:55 pm
#25

I saw that the 1.2 version only sends the emails out when it’s published. What if I publish a story, then edit it to fix a typo for example. Will another e-mail be sent out at this time? Hopefully not but i’m just curious. If it does anyway to fix that?

josh wrote on October 20, 2004 - 11:16 pm
#26

I fixed the plugin so that edited posts do not get emailed out, just new posts.

Gudlyf wrote on October 20, 2004 - 11:19 pm
#27

Ambrose — Do you have any other post formatting plugins installed?

Gudlyf wrote on October 20, 2004 - 11:22 pm
#28

Thanks for the plugin! :) I’m just having one issue. I’ve set up the plugin and I’ve tested and verified that it works for signing people up and sending emails. The problem I’ve having though is that I’ve configured it to send HTML emails but when I receive an email notifying me of a post nothing shows up in the message body in my mail reader (GroupWise). If I switch my mail reader to read text rather than HTML then I see the message, but with all of the html tags as text. I am able to receive and see HTML mail from other sources. I wonder if something is messed up in the headers–maybe dealing with Content-type? Should it be Content-Type: multipart/alternative;?

Steve wrote on November 17, 2004 - 5:27 pm
#29

Oops. I just now figured out that I’m using Brian Groce’s plugin (which I assume is somehow different than this one?) so I’ll go ask over at his blog. Sorry for the confusion.

Steve wrote on November 17, 2004 - 7:25 pm
#30

Does it send notification emails by category? So that only those interested in a certain subject matter will be notified. In other words, notification of specific posts and not of all posts in general.

penny wrote on November 25, 2004 - 2:14 pm
#31

There are a few things I need cleared up in order to understand how this plugin works. Just “plugging it in” and waiting isn’t exactly what makes this work.

1. I assume you have to create a sign up form for people to send you their emails to be notified and that such a form doesn’t come with the plugin.

2. The email list created by the private posting consists of only email addresses and not something like:

fred flintstone,fred@flintstone.com
sally flags,sally@flags.com

In order to have the name and the email in the send email.

3. Is there a similar plug in that automates the system so people can enter their email address into the form and the php coding would insert the info into the database (or post) and then email them automatically without manual insertion of their email into the private posting?

Lorelle VanFossen wrote on January 6, 2005 - 3:05 pm
#32

Thanks for taking the time to write this plugin. It’s definitely useful. I’ve got a feature request (obviously only if you have time – I realize this is volunteer) and a bug report.

Bug: The e-mail list receives notifications when I publish a post in the future. I don’t use this feature very often, but when I do it’s confusing to users who receive a notification but get to a “No posts matched your criteria” page when they click on the link.

Feature request: It would be nice if there were some automatic way for users to be able to subscribe or unsubscribe themselves. I realize this might be a lot of work, but it would make the plugin really solid.

Adam Heine wrote on January 25, 2005 - 10:10 pm
#33

I’m not sure it’s worth updating this plugin anymore, as there are other options out there that allow people to subscribe. If people tell me they still prefer this plugin over those and still want bugs fixed (that future date one is an example), let me know and I’ll try to get to it.

Gudlyf wrote on January 25, 2005 - 11:29 pm
#34

I just installed WP and found your plug-in when looking for an easy way to copy a single person on new entries. I don’t want to install a whole subscription mechanism, so this plug-in was just what I was looking for. If it makes any diff, I’d say it’s a useful alternative.
My only wish is to email the body of the post instead of the link. I tried Michael Higgins’s code above, but php on my server throws an “unexpected T_STRING” error on that code and I can’t grok the why. I think it’s something in the t-sql, but I can;t figure out what – tried all the obvious (missing semi, stuff like that). I’m moving on and leaving it like it is – maybe I’ll come back later…

Anyway, thanks!

Cori Schlegel wrote on March 14, 2005 - 12:46 pm
#35

I just installed WP and found your plug-in when looking for an easy way to copy a single person on new entries. I don’t want to install a whole subscription mechanism, so this plug-in was just what I was looking for. If it makes any diff, I’d say it’s a useful alternative.
My only wish is to email the body of the post instead of the link. I tried Michael Higgins’s code above, but php on my server throws an “unexpected T_STRING” error on that code and I can’t grok the why. I think it’s something in the t-sql, but I can;t figure out what – tried all the obvious (missing semi, stuff like that). I’m moving on and leaving it like it is – maybe I’ll come back later…

Anyway, thanks!

Cori Schlegel (kinrowan) wrote on March 14, 2005 - 1:01 pm
#36

Cory, you can create a category, hide it on the front page and give the rss feed to whoever you want to see it. Much more elegant than email, I think.

charlie wrote on March 14, 2005 - 2:36 pm
#37

Yes, I would agree. Except that my wife doesn’t use RSS and is totally uninterested in learning it. thus the email solution.

cori schlegel (kinrowan) wrote on March 16, 2005 - 6:28 pm
#38

Hello !
I would like to know if it is possible to notify only if there is a new post and not when the post is corrected/updated. Thanks

comments wrote on March 23, 2005 - 9:06 am
#39

Does this plugin work for wp 1.5 or is it still in the works? I used it with my wp 1.2 and it worked but since the upgrade I cant seem to get it to work.
Please send response to email please

Scott wrote on March 29, 2005 - 2:21 pm
#40

Are you going to be updating this plugin to work with wp 1.5?

scott wrote on March 30, 2005 - 3:19 pm
#41

[...] Changes Bible references to hyperlinks (Example John 3:16) Update Notify - Notifies an email list of the site having updated or new entries.

« [...]

Media4God Ministries » WordPress Plugins I Use wrote on May 6, 2005 - 1:20 am
#42

[...] ized — media4god @ 10:55 PM

 Microsoft  John 3:16  Update Notify -Notifies an email list of the site having updated or new entries.  WYSIWYG II Plugin for [...]

#43

[...] dPress, e a dire il vero l’argomento gia’ mi solleticava, quindi ho collaudato il plug-in Update Notify presente su Gudly’f World, e pare che funzioni. Se vi siete [...]

#44

Is there a way to make the mailing list choose-able? That is to say, having a option when posting to select a list of people to send the post to, or turn off the sending e-mail option completely. I hope this is not too hard to do..

SZH wrote on June 30, 2005 - 11:12 am
#45

[...] Email about changes to site to a list of folks: http://www.gudlyf.com/index.php?p=357 [...]

FirstPersonShow.net » Blog Archive » Misc Stuff wrote on August 7, 2005 - 3:56 am
#46

Everything works fine *except* the permalink in the email It’s always “http://lindsaystephproject.com/?p=” without the id. I checked and $post_ID is null when the plugin is run. Any ideas?

Lindsay wrote on June 11, 2006 - 2:48 pm
#47

I figured it out. This:

function update_notify() {

global $post_ID, $wpdb;
global $tableposts;

Should really be this:


function update_notify($post_ID) {

global $wpdb;
global $tableposts;

it works for me now!

Lindsay wrote on June 11, 2006 - 2:55 pm
#48

Very nice little plugin! Thanks Gudlyf! It works, only the thing that Lindsay mentioned is not working for me. I still have http://mysite.com/?p= with an empty ID that links only to my main page but not to the new written post.
Any ideas?

Would be great to include the title of the new post as well (as a little teaser ;-) ). Has anyone an idea how to do with PHP?

Cheers, Anja

Anja wrote on August 4, 2006 - 5:33 am
#49

Hi Gudlyf, great little plugin! It works for me, except I have the same problem as Lindsay above mentioned. My ID is still empty and the link leads only to my main blog page, not to the new article.
Any ideas? I use WP 2.0.4.

Would be nice to include the title of the new post in the email as well (as a teaser ;) ). Does anyone know how do write/do this with PHP?

Cheers, Anja

Anja wrote on August 4, 2006 - 5:36 am
#50

Great script–
Is it possible to get it to notify the email (which is me, for now) and include in the email the first 3-4 lines of the post, then the Post’s full url. And then could it be made to put the full title in the subject of the email sent out?

I’d be willing to pay tribute to you oh Gudly if you could do this. I need to repost some stuff to another blog or two and if I could sort of have your email pre package the email I get then I can do some simple edits and forward it to the other blogs.

Should be doable, right?

mark wrote on February 17, 2007 - 1:01 pm
#52

Hello,

Am looking for a WordPress plugin with this functionality but is “Update Notify” still supported? Since latest plugin update is from May 2004.

Cheers

jotrys wrote on June 25, 2007 - 7:02 am
#53

Sometimes the “get_permalink($post_ID)” will write the Post page (w/ comments) link, and sometimes it writes the Archive page link.

I need it to always write the Post page link. Does anyone know what could be causing this?

thanks

Greg wrote on July 16, 2007 - 11:47 pm
#54

Hi Gudlyf,
I think your plugin is just what I’m looking for. However, I can’t quite get it to work right.
I have installed the update-notify.php file in wp-content/plugins and I created a private post with 2 email addresses called update-notify.

When I attempt to publish a post, I get this error:
Warning: Invalid argument supplied for foreach() in /opt/lampp/htdocs/wp-content/plugins/update-notify.php on line 45

Warning: Cannot modify header information – headers already sent by (output started at /opt/lampp/htdocs/wp-content/plugins/update-notify.php:45) in /opt/lampp/htdocs/wp-includes/pluggable.php on line 331

The only other plugins installed are two that came with WP – Akismet and Hello Dolly.

I hope you don’t mind supporting this code still. Any help you could offer would be great. Thanks!

JeniQ wrote on July 20, 2007 - 6:39 pm
#55

will it work with the latest WP upgrade ?

paint protection wrote on November 15, 2007 - 9:44 pm
#56

The plugin works, I mean it sends eMail, but it doesn’t include a link to the new post or page at the blog.

Paula wrote on February 20, 2008 - 1:45 am
Both comments and pings are currently closed.