WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Самая быстрая Тема-конструктор для WordPress
функция не описана

PHPMailer\PHPMailer

PHPMailer::addAttachment() public WP 1.0

Add an attachment from a path on the filesystem. Never use a user-supplied path to a file! Returns false if the file could not be found or read. Explicitly does not support passing URLs; PHPMailer is not an HTTP client. If you need to do that, fetch the resource yourself and pass it in via a local file or string.

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

Хуков нет.

Возвращает

true/false.

Использование

$PHPMailer = new PHPMailer();
$PHPMailer->addAttachment(;
$path(строка) (обязательный)
Path to the attachment
$name(строка) (обязательный)
Overrides the attachment name
$encoding(строка) (обязательный)
File encoding ($Encoding)
$type(строка) (обязательный)
File extension (MIME) type
$disposition(строка) (обязательный)
Disposition to use

Код PHPMailer::addAttachment() WP 5.5.1

<?php
public function addAttachment(
    $path,
    $name = '',
    $encoding = self::ENCODING_BASE64,
    $type = '',
    $disposition = 'attachment'
) {
    try {
        if (!static::isPermittedPath($path) || !@is_file($path) || !is_readable($path)) {
            throw new Exception($this->lang('file_access') . $path, self::STOP_CONTINUE);
        }

        // If a MIME type is not specified, try to work it out from the file name
        if ('' === $type) {
            $type = static::filenameToType($path);
        }

        $filename = (string) static::mb_pathinfo($path, PATHINFO_BASENAME);
        if ('' === $name) {
            $name = $filename;
        }

        if (!$this->validateEncoding($encoding)) {
            throw new Exception($this->lang('encoding') . $encoding);
        }

        $this->attachment[] = [
            0 => $path,
            1 => $filename,
            2 => $name,
            3 => $encoding,
            4 => $type,
            5 => false, // isStringAttachment
            6 => $disposition,
            7 => $name,
        ];
    } catch (Exception $exc) {
        $this->setError($exc->getMessage());
        $this->edebug($exc->getMessage());
        if ($this->exceptions) {
            throw $exc;
        }

        return false;
    }

    return true;
}