Home » 2005 » February » 21

Daily Archives: Monday, February 21, 2005

The Most Versatile VoIP Provider: FREE PORTING

ISP-In-A-Box: The $500 Mac mini (Chapter XII, Email Reminders)

One of the most useful additions to any server is the ability to send yourself or others Email Reminders. Adding a web interface is simply icing on the cake. Yes, PDAs and cell phones and iCal can do it as stand-alone applications, but you have to be with the device where you scheduled the reminder, or you miss it. With a web-based email reminder system, you can send reminders to multiple devices and multiple people, not just yourself… and you can schedule them up to nine years in advance (assuming your server makes it that long). If you have teenagers, I don’t have to tell you how much they will appreciate your computer sending their cellphones reminders to clean their rooms in the middle of their night on the town. It also comes in handy to make sure you pay bills on time. And, you’ll find it absolutely essential in getting out of boring meetings early by simply sending your cellphone an urgent message at the top of the hour. Yes, the reminders can be recurring: every hour, every day, every month, or every year. And no, email reminders won’t cost you a dime. Unfortunately, it’s another of those little Linux gems that just didn’t quite fit the Mac way of doing things. So, we’ve fixed it up, added the missing pieces for MySQL and Perl, and repackaged it for all the Mac addicts who have built one of our ISP-In-A-Box systems these past few weeks.

Prerequisites. Before Email Reminders will work on your Mac, you’ll need to assure that you’ve enabled the Apache Web Server, the Postfix SMTP email server (POP and IMAP are not required!), the MySQL database server, PHP, and PhpMyAdmin. You’ll also need Webmin to add the crontab scheduling piece unless you’re familiar with using crontab directly … which we’re going to cover later this week, incidentally. For Email Reminders to function properly after installation, you’ll need to keep the following servers running all the time: Apache, Postfix SMTP, and MySQL. Aren’t you glad you bought that extra RAM!

Our approach should be getting familiar by now. We’ll download the software to your desktop, then move it to its permanent home on your web server. Next, we’ll run a simple MySQL script to create the necessary database to manage your reminders. Then we’ll customize the software to add your email return address. And finally, we’ll set up a crontab script to check for reminders to be sent at the top of every hour.

Downloading Email Reminders. You can learn all about Email Reminders at the author’s web site, but unfortunately for Mac users, the version available there just doesn’t quite work as packaged with Mac OS X. So we’ve customized the software a bit to match our ISP-In-A-Box configuration, and it’s available for download here. Once the 100K download to your Desktop completes, it should decompress into a folder named emrem. If not, double-click on the downloaded file to start the process.

Moving Email Reminders to Your Web Site. Open a Finder window, click on your local hard disk, and navigate to the /Library/WebServer/Documents folder. Then click-and-drag the emrem folder on your Desktop into the Documents folder. This will make your Email Reminders application available with a web browser using the syntax: http://yourdomain.com/emrem/ or http://localhost/emrem/ from your server desktop.

Building the Email Reminders MySQL Database. Open a Terminal window and switch to root user access: sudo su. Now move to the folder where we installed emrem:

  • cd /Library/WebServer/Documents/emrem
  • After making certain that MySQL is running (/library/startupitems/mysql/mysql restart), type the following command to create your Email Reminder database:

  • /usr/local/mysql/bin/mysql < emrem.sql
  • Customizing Email Reminders. While you’re still positioned in the emrem folder, let’s add your own email return address just so email reminders don’t get bounced as spam. We’ll edit the configuration file with out usual Pico editor and, yes, BE CAREFUL: pico config.php. Now search for yourname: CTRL-W, yourname, then enter. Carefully delete yourname@yourdomain.com using the CTRL-D key. Now type your email address in its place. Save your changes: CTRL-X, Y, then enter.

    Verifying All Is Well. Let’s run a simple test to be sure everything worked according to plan thus far. After assuring that your web server is running, switch to a web browser and go to http://localhost/emrem/. Now add an entry to send an Email Reminder to your own email address and schedule it for the next hour. Once you get a completed message, let’s use PhpMyAdmin to verify that the reminder was actually placed in the MySQL database we set up. Start PhpMyAdmin: http://localhost/php/. Click on the Databases pull-down and choose the emrem database. Now click on the reminders table, and choose the Browse tab. You should see one entry in your table. You can close your browser window now, but keep in mind that this is where you’d come to delete a reminder if, for some reason, something ever goes haywire. I’ve never seen it happen in four years of use!

    Scheduling the Email Reminders Task. Finally, we need to schedule the Email Reminders Perl script to run each hour. It is responsible for checking to see if reminders are due to be sent and sending them. Start up Webmin if it is not already running on your server: /etc/webmin/start. Now open Webmin with your browser: http://localhost:10000. Enter admin for your username and your actual password. Click on the System button and then Scheduled Cron Jobs. Then click Create a new scheduled cron job. Make the following entries in the form and then click the Create button. Leave the default settings unless specified below:

  • Execute cron job asroot
  • Command/Library/WebServer/Documents/emrem/cron-emrem.pl
  • When to executeTimes and dates shown below
  • Minuteclick on Selected and click on the number 1
  • Hours, Days, Months, WeekdaysAll
  • Now all you have to do is wait for the top of the hour, and your first Email Reminder should arrive within a minute or two. Before redistributing this software, please read the license terms in the COPYING file which can be found in the emrem folder on your web site. Enjoy!