How CouchDB was born

January 2nd, 2011

Damien Katz explains what drove him to create CouchDB.

Email notifier in PHP

March 4th, 2009

I like writing simple and practical scripts that solve real problems. I needed an e-mail monitor for checking new messages with SMS notification. Since SMS messages cost money and I get lots of spams every day, it is very important that I am notified only when an important e-mail arrives.

And the solution:

For sending SMS messages I chose to use SmsBug (smsbug.com) SMS gateway as I am satisfied with its quality and price.
The script includes a class written by me for interacting with SmsBug’s service.
I use PHP IMAP extension to retrieve the list of e-mails. List of e-mails are filtered by the sender’s address. Allowed senders (e-mails from these senders are probably important) are specified by PERL regular expression. Concrete e-mail addresses can be listed or e-mail addresses under a certain domain name. Let us see an example on how to by notified when an e-mail is received from either w3net.eu, cnn.com, or gmail.com domains:

The email’s header is checked for a match with the given regular expression. If matches, the e-mail is considered to be important. I must say that I was lazy to check the sender’s address, I look for matches in the entire e-mail header (maybe in the next version).

Here comes another example. Say we want to be notified when we receive an e-mail from our boss or an e-mail from any gmail account.

Schedule the script

The script always looks for e-mails received yesterday (you can change this). It is sufficient for me to be notified of e-mails received yesterday. I scheduled the script to be executed every day at 10 AM. When I am at work I usually have downloaded my e-mails by 10AM. When the notifier is executed at 10AM, the e-mail box is already empty by that time. But when I am on holiday (or in hospital), e-mails are not downloaded, so the script will find the e-mails and would notify my by SMS message if the e-mail is from an important sender. The SMS message contains only the sender’s e-mail address, time, and subject of the message.

If you wish to monitor your GMail account you need to use the configuration I put between comments. I tested it with my GMail account, it appeared to work fine with.

Almost a year after the first release of the Easy PHP File uploader PHP script I released a new version.
I improved the script to allow multiple file upload. This feature is disabled by default, so you need to enable it. It is not a bug fix release. Those of you who are not interested in this new feature do not need to upgrade their code.

How to enable multiple file upload?

  1. Uncomment the following line in index.php file.
    <a href="#" id="lnkAddNewFileInputBox">more files</a>
  2. Replace value none with decimal in the following line in main.css file.

    
    #fileBoxesLst li {
        list-style-type: none; /* decimal */
    }
    

It is also possible to have a fixed number of file upload input boxes. Remove or comment the "more files" link.
Then add as many file upload boxes as you need. For example:

more-file-input-boxes.png

Links