PHPMailer::addOrEnqueueAnAddress()protectedWP 1.0

Add an address to one of the recipient arrays or to the ReplyTo array. Because PHPMailer can't validate addresses with an IDN without knowing the PHPMailer::$CharSet (that can still be modified after calling this function), addition of such addresses is delayed until send(). Addresses that have been added already return false, but do not throw exceptions.

{} It's a method of the class: PHPMailer{}

No Hooks.


true|false. true on success, false if address already used or invalid in some way


// protected - for code of main (parent) or child class
$result = $this->addOrEnqueueAnAddress( $kind, $address, $name );
$kind(string) (required)
One of 'to', 'cc', 'bcc', or 'ReplyTo'
$address(string) (required)
The email address to send, resp. to reply to
$name(string) (required)

Code of PHPMailer::addOrEnqueueAnAddress() WP 6.0

protected function addOrEnqueueAnAddress($kind, $address, $name)
    $address = trim($address);
    $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
    $pos = strrpos($address, '@');
    if (false === $pos) {
        //At-sign is missing.
        $error_message = sprintf(
            '%s (%s): %s',
        if ($this->exceptions) {
            throw new Exception($error_message);

        return false;
    $params = [$kind, $address, $name];
    //Enqueue addresses with IDN until we know the PHPMailer::$CharSet.
    if (static::idnSupported() && $this->has8bitChars(substr($address, ++$pos))) {
        if ('Reply-To' !== $kind) {
            if (!array_key_exists($address, $this->RecipientsQueue)) {
                $this->RecipientsQueue[$address] = $params;

                return true;
        } elseif (!array_key_exists($address, $this->ReplyToQueue)) {
            $this->ReplyToQueue[$address] = $params;

            return true;

        return false;

    //Immediately add standard addresses without IDN.
    return call_user_func_array([$this, 'addAnAddress'], $params);