PHP ezmlm_hash() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Mail

Definition

In PHP, ezmlm_hash() calculated the hash value that EZMLM mailing list software expects for an email address.

It was deprecated in PHP 7.2 and removed in PHP 8.0. Most beginners should learn mail() instead. If you still maintain EZMLM files on PHP 8, copy a small userland helper that uses the same algorithm.

Syntax

Call ezmlm_hash() with the values you need. Start with this line.

PHP
// Removed in PHP 8.0 — use a userland helper instead
$hash = ezmlm_hash_compat('[email protected]');
CallWhat it does
ezmlm_hash_compat('[email protected]')Userland replacement that returns the same style of EZMLM hash integer.
ezmlm_hash_compat(strtolower($email))Lowercasing first matches how the old function treated letters.
(string) ezmlm_hash_compat($email)Cast the hash to a string when you need it as a folder name.

Do not call ezmlm_hash() on PHP 8 — it no longer exists. The examples on this page use ezmlm_hash_compat(), a short replacement you can paste into your project.

Library declarations
PHP
ezmlm_hash(string $addr): int

Parameters

ParameterDescription
addrRequired. Historical: the email address to hash, for example [email protected].

Return Value

Return ValueDescription
intHistorical: the EZMLM hash for that address (0–52). Use it as the subscriber directory name EZMLM expects.

PHP Examples

Example 1 — Userland Replacement Hash

Paste a compatible helper and hash a fixed address. This works on PHP 8.

PHP
<?php
function ezmlm_hash_compat(string $addr): int
{
    $h = 5381;
    $addr = strtolower($addr);
    $len = strlen($addr);
    for ($i = 0; $i < $len; $i++) {
        $h = (($h + ($h << 5)) ^ ord($addr[$i])) & 0xFFFFFFFF;
    }
    return $h % 53;
}

$email = '[email protected]';
$hash = ezmlm_hash_compat($email);
echo $email, ' => ', $hash, PHP_EOL;

How It Works

  1. Define ezmlm_hash_compat() with the old algorithm.
  2. Store a sample address in $email.
  3. Call the helper to get an integer from 0 to 52.
  4. Print the address and the hash together.

Example 2 — Compare Two Addresses

Different addresses usually produce different hashes.

PHP
<?php
function ezmlm_hash_compat(string $addr): int
{
    $h = 5381;
    $addr = strtolower($addr);
    $len = strlen($addr);
    for ($i = 0; $i < $len; $i++) {
        $h = (($h + ($h << 5)) ^ ord($addr[$i])) & 0xFFFFFFFF;
    }
    return $h % 53;
}

$a = ezmlm_hash_compat('[email protected]');
$b = ezmlm_hash_compat('[email protected]');
echo 'alice: ', $a, PHP_EOL;
echo 'bob: ', $b, PHP_EOL;
echo 'same? ', $a === $b ? 'yes' : 'no', PHP_EOL;

How It Works

  1. Hash alice@example. com with the helper.
  2. Hash bob@example. com the same way.
  3. Print each integer result.
  4. Compare the two values with ===.

Example 3 — Build an EZMLM-Style Path

Show how a hosting script might turn the hash into a directory name.

PHP
<?php
function ezmlm_hash_compat(string $addr): int
{
    $h = 5381;
    $addr = strtolower($addr);
    $len = strlen($addr);
    for ($i = 0; $i < $len; $i++) {
        $h = (($h + ($h << 5)) ^ ord($addr[$i])) & 0xFFFFFFFF;
    }
    return $h % 53;
}

$email = '[email protected]';
$hash = ezmlm_hash_compat($email);
$path = '/var/qmail/ezmlm/list/' . $hash . '/';
echo 'hash: ', $hash, PHP_EOL;
echo 'path: ', $path, PHP_EOL;

How It Works

  1. Choose a subscriber address.
  2. Compute its EZMLM-style hash with the helper.
  3. Append the hash to a base list path.
  4. Print the hash and the finished path string.

Frequently Asked Questions

It returned the integer hash that EZMLM mailing list software uses for an email address when storing subscriber files.
The function was removed in PHP 8.0. Use a userland replacement such as ezmlm_hash_compat() if you still need the hash, or ignore it if you only send mail with mail().
No. It only calculated a number. Use mail() when you want PHP to hand a message to the server mailer.
Only when you work with EZMLM subscriber directories. Most PHP apps never need it.
Learn mail() for sending messages, how headers work, and how to avoid header injection.

Next: mail()

mail() asks the server mail system to send an email message.

mail() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful