PHPMailer\PHPMailer

PHPMailer::addStringEmbeddedImage │ public │ WP 1.0

Add an embedded stringified attachment. This can include images, sounds, and just about any other document type. If your filename doesn't contain an extension, be sure to set the $type to an appropriate MIME type.

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

Хуков нет.

Возвращает

bool. True on successfully adding an attachment

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

$PHPMailer = new PHPMailer();
$PHPMailer->addStringEmbeddedImage( $string, $cid, $name, $encoding, $type, $disposition );
$string(строка) (обязательный)
The attachment binary data.
$cid(строка) (обязательный)
Content ID of the attachment; Use this to reference the content when using an embedded image in HTML.
$name(строка)
A filename for the attachment. If this contains an extension, PHPMailer will attempt to set a MIME type for the attachment. For example 'file.jpg' would get an 'image/jpeg' MIME type.
По умолчанию: ''
$encoding(строка)
File encoding (see $Encoding).
По умолчанию: 'base64'
$type(строка)
MIME type - will be used in preference to any automatically derived type.
По умолчанию: ''
$disposition(строка)
Disposition to use.
По умолчанию: 'inline'

Код PHPMailer::addStringEmbeddedImage() WP 7.1.2

public function addStringEmbeddedImage(
    $string,
    $cid,
    $name = '',
    $encoding = self::ENCODING_BASE64,
    $type = '',
    $disposition = 'inline'
) {
    try {
        //If a MIME type is not specified, try to work it out from the name
        if ('' === $type && !empty($name)) {
            $type = static::filenameToType($name);
        }

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

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

        return false;
    }

    return true;
}