The mail server is sending multiple messages each with a unique ID. How do you explain that?

I suggest you rewrite the code for birthday emails as follows:
Code
function trigger_birthday_notifications($sent, $rightnow, $today) {
    global $config, $dbh, $html, $user, $ubbt_lang;

    // Start transaction
    $dbh->begin_transaction();

    try {
        // Lock the birthdays cache row to prevent concurrent execution
        $query = "SELECT CACHE_VALUE FROM {$config['TABLE_PREFIX']}CACHE WHERE CACHE_FIELD = 'birthdays' FOR UPDATE";
        $sth = $dbh->do_query($query, __LINE__, __FILE__);
        $current_status = $dbh->fetch_array($sth)[0];

        // If it's in pending mode, check if stuck (over 1 hour)
        if (preg_match("#PENDING#", $current_status)) {
            $status = preg_replace("#PENDING-#", "", $current_status);
            if (($rightnow - $status) < 3600) {
                $dbh->rollback();
                return;
            }
        }

        // Update cache with new pending status
        $query = "UPDATE {$config['TABLE_PREFIX']}CACHE SET CACHE_VALUE = ? WHERE CACHE_FIELD = ? AND CACHE_VALUE = ?";
        $dbh->do_placeholder_query($query, array("PENDING-$rightnow", 'birthdays', $current_status), __LINE__, __FILE__);

        // If no rows affected, another process is handling it
        if (!$dbh->affected_rows()) {
            $dbh->rollback();
            return;
        }

        // Convert time to birthday format (UTC)
        $birthday = $html->convert_time($rightnow, 0, "n/j/", 1, 0);

        // Query members with birthdays today
        $query = "
            SELECT t1.USER_DISPLAY_NAME, t2.USER_REAL_EMAIL, t2.USER_LANGUAGE
            FROM {$config['TABLE_PREFIX']}USER_PROFILE AS t2,
                 {$config['TABLE_PREFIX']}USERS AS t1
            WHERE t1.USER_ID = t2.USER_ID
              AND t2.USER_BIRTHDAY LIKE '$birthday%'
              AND t1.USER_IS_BANNED = 0
              AND t2.USER_ACCEPT_ADMIN_EMAILS = 'On'
        ";
        $sth = $dbh->do_query($query, __LINE__, __FILE__);

        $mailer = new mailer();
        while (list($bname, $b_email, $b_lang) = $dbh->fetch_array($sth)) {
            $mailer->set_language($b_lang);
            $mailer->set_subject('BDAY_SUBJECT', array('BOARD_TITLE' => $config['COMMUNITY_TITLE']));
            $mailer->set_salute('EMAIL_SALUTE', array('USERNAME' => $bname));
            $mailer->add_content('BDAY_CONTENT', array('BOARD_TITLE' => $config['COMMUNITY_TITLE']));
            $mailer->ubbt_mail($b_email);

            // Log this action
            admin_log("MAIL_BIRTHDAY", $bname . " (" . $b_email . ")");
        }

        // Update cache to mark as sent
        $query = "UPDATE {$config['TABLE_PREFIX']}CACHE SET CACHE_VALUE = ? WHERE CACHE_FIELD = 'birthdays'";
        $dbh->do_placeholder_query($query, array($today), __LINE__, __FILE__);

        // Commit transaction
        $dbh->commit();
    } catch (Exception $e) {
        $dbh->rollback();
        throw $e; // Handle or log error as needed
    }
}


The Stovebolt Geek
https://www.stovebolt.com/ubbthreads/ubbthreads.php

Server Information
UBB.threads Version 8.0.0
Release 20240826
Server OS Linux
Server Load 0.11
Web Server Apache/2.4.37
PHP Version 8.3.11
MYSQL Version 8.0.39
Database Size 1.82 GB