DQuinn.net

Web Design

Autoupdate Thunderbird Signature with Your Latest WordPress Post

Bored of having the same old signature line in Thunderbird? Instead of a stale link back to your blog, why not have a link to the latest post on your blog?

Here’s dirty hack for shits and giggles. Ever get bored of having the same old signature line in Thunderbird? Instead of a stale link back to your blog, why not have a link to the latest post on your blog?

Note: In order for this setup to work, you need to have PHP installed locally.

So this is what we’re going to do: First, we’ll write a quick local PHP script that parses the RSS feed of your blog, to get the latest blog post’s URL and title. Then, we’ll save that information to a .txt file, which you will set as your signature in Thunderbird. Finally, we’ll write .vbs and .bat files that will open your script, update the .txt file, and then close themselves as your computer boots. All you need is a text editor to do this.

First, download this RSS parser and drop it in a folder in your webdev directory. Next, create a file in the same folder called signature-get.php, with the following code:

Be sure to replace my URL and feed with your own. This was written for a WordPress feed, but with minimal tweaking it should work with any valid RSS. Next, make a blank signature file—mine is called “Signature.txt”—in the same folder. This is what the PHP script will write to. You must assign this file as your signature in Thunderbird, like so:

At this point, if you run the script from your local webserver, you should find that your Signature.txt gets updated with the latest blog post, like so:

Now we need to run this guy whenever we start our comp, because we are lazy. We don’t want a browser window to open up and stay open when we start up the computer (because that’s annoying), so we’ll command Internet Explorer to open the URL of our script in the background (I do love ordering IE around to do mundane, non-webpage-related tasks. Since the web is clearly not it’s specialty…).

Create a .vbs file in the same folder, called “IE.vbs.” (I scrubbed this code from a forum.) Put the following in it:

Okay, so far so good. Make sure that the path “http://localhost/thunderbird/signature-get.php” matches the path to your script on your local webserver. Next, let’s run IE.vb in a batch file. Call this guy “update.bat” and save it in the same folder you’ve saved everything else:

The “exit” may or may not be necessary. Too lazy to double-check. What’s happening here is that we create a .vbs script that waits for 30 seconds and then gets deleted after the wait, effectively delaying our setup long enough for your webserver to kick in, before our PHP script runs.

Finally, drag and drop a shortcut to update.bat into your Startup folder in the Start Menu, and you’re good to go. At startup, the command window will stay open for a few seconds while the script runs, and then go away by itself.

Obviously, there are better ways to go about doing this, but this works great for me, so I thought I’d share.


Also in Web Design


Post a Comment

Your Two Cents

Reply

Your Comments

0 Replies & Counting

There are no comments yet.