PHPMailer::mailSend()protectedWP 1.0

Send mail using the PHP mail() function.

Метод класса: PHPMailer{}

Хуков нет.




// protected - в коде основоного (родительского) или дочернего класса
$result = $this->mailSend( $header, $body );
$header(строка) (обязательный)
The message headers
$body(строка) (обязательный)
The message body


Код PHPMailer::mailSend() WP 6.5.2

protected function mailSend($header, $body)
    $header = static::stripTrailingWSP($header) . static::$LE . static::$LE;

    $toArr = [];
    foreach ($this->to as $toaddr) {
        $toArr[] = $this->addrFormat($toaddr);
    $to = trim(implode(', ', $toArr));

    //If there are no To-addresses (e.g. when sending only to BCC-addresses)
    //the following should be added to get a correct DKIM-signature.
    //Compare with $this->preSend()
    if ($to === '') {
        $to = 'undisclosed-recipients:;';

    $params = null;
    //This sets the SMTP envelope sender which gets turned into a return-path header by the receiver
    //A space after `-f` is optional, but there is a long history of its presence
    //causing problems, so we don't use one
    //Exim docs:
    //Sendmail docs:
    //Qmail docs:
    //Example problem:
    //CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped.

    //PHP 5.6 workaround
    $sendmail_from_value = ini_get('sendmail_from');
    if (empty($this->Sender) && !empty($sendmail_from_value)) {
        //PHP config has a sender address we can use
        $this->Sender = ini_get('sendmail_from');
    if (!empty($this->Sender) && static::validateAddress($this->Sender)) {
        if (self::isShellSafe($this->Sender)) {
            $params = sprintf('-f%s', $this->Sender);
        $old_from = ini_get('sendmail_from');
        ini_set('sendmail_from', $this->Sender);
    $result = false;
    if ($this->SingleTo && count($toArr) > 1) {
        foreach ($toArr as $toAddr) {
            $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params);
            $addrinfo = static::parseAddresses($toAddr, true, $this->CharSet);
                [[$addrinfo['address'], $addrinfo['name']]],
    } else {
        $result = $this->mailPassthru($to, $this->Subject, $body, $header, $params);
        $this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From, []);
    if (isset($old_from)) {
        ini_set('sendmail_from', $old_from);
    if (!$result) {
        throw new Exception($this->lang('instantiate'), self::STOP_CRITICAL);

    return true;