CodShot
PHP Public

Load PHPMailer Library Once

This function loads the three essential PHPMailer files only once to prevent multiple inclusions during execution.

PHP
<?php

function mailer_require_phpmailer(): void
{
    static $loaded = false;

    if ($loaded) {
        return;
    }

    $base = APP_PATH . '/libraries/PHPMailer/src';

    require_once $base . '/Exception.php';
    require_once $base . '/PHPMailer.php';
    require_once $base . '/SMTP.php';

    $loaded = true;
}

Snippet actions

Pluto
Pluto
Updated: 2026-08-24 08:10
Public snippets
0
Forks
CodShot AI Help
Ask about CodShot features, plans, workspace, AI limits, referrals, and public help topics.
Hi! I can help you understand how CodShot works. What would you like to know?
For account-specific or sensitive issues, please open a support ticket. Open support