Source of badhelo_php:
Show as raw file
#! /usr/local/bin/php
<?php
/*
 * Copyright (C) 2003-2004 Pawel Foremski <pjf@gna.org>
 *
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public License 
 * as published by the Free Software Foundation; either 
 * version 2 of the License, or (at your option) any later 
 * version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 ***
 *
 * $Id: badhelo.php,v 1.1 2004/07/05 18:27:21 pavcio Exp $
 *
 */


/*** configuration ***/

/* full path to badhelo file */
$badhelo_file '/var/qmail/control/badhelo';

/*********************/

error_reporting(0);

if (
$_ENV['NOBADHELO'] !== NULL ||  /* plugin disabled */
    
!$_ENV['SMTPHELOHOST']) exit(); /* no HELO host */

/* read badhelo file */
if (!file_exists($badhelo_file)) exit("E451 badhelo file does not exist (#4.3.0)\n");
if ((
$badhelo file($badhelo_file)) === FALSE) exit("E451 badhelo file read error (#4.3.0)\n");
if (!
count($badhelo)) exit(); /* file empty */

/* search */
foreach ($badhelo as $line) {
    
$line trim($line);
    if (
$line[0] == '#') continue; /* skip comments */

    
if (fnmatch($line$_ENV['SMTPHELOHOST'])) {
        
fwrite(STDERR"invalid HELO greeting: $_ENV[SMTPHELOHOST]\n");
        exit(
"E551 sorry, your HELO/EHLO greeting is in my badhelo list (#5.7.1)\n");
    }
}

?>