SquirrelMail Simple Compose Captcha System

Author: Catalin Constantin
Contact: dazoot@gmail.com
Date: 6 Aug 2005
Web site:http://opensource.dazoot.ro/member/catalin/squirrelmail_captcha/
Copyright: This document has been placed in the public domain.

Contents

About

This simple Squirrel Mail plugin prevents spam bots from sending email using the squirrel mail web interface. Using the Captcha system it distinguishes from humans and computers.

Requirements

PEAR::Text_Password - for password generation (already included in the distribution)

GD Library - for image generation (png / jpg / gif)

Instalation

  1. Download the source code from here:

    http://opensource.dazoot.ro/member/catalin/squirrelmail_captcha/download/compose_captcha-0.1.tar.gz

  2. Unzip the archive into the squirrel mail plugins folder

  3. Patch compose.php to support the new feature like follows:

    After the subject field is "printed" add a call for do_hook('compose_after_subject');:

    echo '         '.addInput('subject', $subject, 60).
         '      </td>' . "\n" .
         '   </tr>' . "\n\n";
    
    // begin here
    do_hook('compose_after_subject');
    // end here
    
    if ($location_of_buttons == 'between') {
        showComposeButtonRow();
    }
    
    /* why this distinction? */
    if ($compose_new_win == '1') {
    

    Now add the check in the checkInput function, when the Send Button is pressed:

    function checkInput ($show) {
        /*
         * I implemented the $show variable because the error messages
         * were getting sent before the page header.  So, I check once
         * using $show=false, and then when i'm ready to display the error
         * message, show=true
         */
        global $body, $send_to, $send_to_bcc, $subject, $color;
    
            // begin here
            if (strcasecmp($_SESSION["captcha_phrase"], $_POST["captcha_phrase"]) || strlen($_POST["captcha_phrase"])<1 )
            {
                    if ($show) plain_error_message(_("The verification code is incorrect."), $color);
            return false;
            }
            // end here
            
            if ($send_to == '' && $send_to_bcc == '') {
                if ($show) {
                    plain_error_message(_("You have not filled in the \"To:\" field."), $color);
                }
                return false;
            }
        
        
        return true;
    } /* function checkInput() */   
    
  4. Run ./configure from the squirrelmail root folder and add the compose_captcha plugin.

Screen Shots

Here are some screenshots with the compose page using the captcha plugin:

  1. Romanian language with white background for the captcha code:

    SquirrelMail Simple Compose Captcha - screenshot 1

  2. English version with transparent background for the captcha code and the error message when the code is not entered corectly:

    SquirrelMail Simple Compose Captcha - screenshot 2

Suggestions

Other suggested plugins for antispam sending from SquirrelMail:

Restrict Senders - limits the nr of recipients per mail and also the number of mails / day for an user.

Links: Open Source, Squirrel Mail, PHP PEAR