function SMTP::recipient

5.x SMTP.php public SMTP::recipient($address, $dsn = '')

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>.

Parameters

string $address The address the message is being sent to:

string $dsn Comma separated list of DSN notifications. NEVER, SUCCESS, FAILURE: or DELAY. If you specify NEVER all other notifications are ignored.

Return value

bool

File

inc/PHPMailer/src/SMTP.php, line 861

Class

SMTP
PHPMailer RFC821 SMTP email transport class. Implements RFC 821 SMTP commands and provides some utility methods for sending mail to an SMTP server.

Code

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]);
}