PHPMailer\PHPMailer

SMTP::recipient()publicWP 1.0

Send an SMTP RCPT command. Sets the TO argument to $toaddr. Returns true if the recipient was accepted false if it was rejected. Implements from RFC 821: RCPT <SP> TO:<forward-path> <CRLF>.

Method of the class: SMTP{}

No Hooks.

Return

true|false.

Usage

$SMTP = new SMTP();
$SMTP->recipient( $address, $dsn );
$address(string) (required)
The address the message is being sent to
$dsn(string)
Comma separated list of DSN notifications. NEVER, SUCCESS, FAILURE or DELAY. If you specify NEVER all other notifications are ignored.
Default: ''

SMTP::recipient() code WP 6.5.2

public function recipient($address, $dsn = '')
{
    if (empty($dsn)) {
        $rcpt = 'RCPT TO:<' . $address . '>';
    } else {
        $dsn = strtoupper($dsn);
        $notify = [];

        if (strpos($dsn, 'NEVER') !== false) {
            $notify[] = 'NEVER';
        } else {
            foreach (['SUCCESS', 'FAILURE', 'DELAY'] as $value) {
                if (strpos($dsn, $value) !== false) {
                    $notify[] = $value;
                }
            }
        }

        $rcpt = 'RCPT TO:<' . $address . '> NOTIFY=' . implode(',', $notify);
    }

    return $this->sendCommand(
        'RCPT TO',
        $rcpt,
        [250, 251]
    );
}