PHPMailer\PHPMailer
PHPMailer::addStringAttachment
Add a string or binary attachment (non-filesystem). This method can be used to attach ascii or binary data, such as a BLOB record from a database.
Метод класса: PHPMailer{}
Хуков нет.
Возвращает
true|false. True on successfully adding an attachment
Использование
$PHPMailer = new PHPMailer(); $PHPMailer->addStringAttachment( $string, $filename, $encoding, $type, $disposition );
- $string(строка) (обязательный)
- String attachment data.
- $filename(строка) (обязательный)
- Name of the attachment.
- $encoding(строка)
- File encoding (see
$Encoding).
По умолчанию:self::ENCODING_BASE64 - $type(строка)
- File extension (MIME) type.
По умолчанию:'' - $disposition(строка)
- Disposition to use.
По умолчанию:'attachment'
Код PHPMailer::addStringAttachment() PHPMailer::addStringAttachment WP 7.0
public function addStringAttachment(
$string,
$filename,
$encoding = self::ENCODING_BASE64,
$type = '',
$disposition = 'attachment'
) {
try {
//If a MIME type is not specified, try to work it out from the file name
if ('' === $type) {
$type = static::filenameToType($filename);
}
if (!$this->validateEncoding($encoding)) {
throw new Exception(self::lang('encoding') . $encoding);
}
//Append to $attachment array
$this->attachment[] = [
0 => $string,
1 => $filename,
2 => static::mb_pathinfo($filename, PATHINFO_BASENAME),
3 => $encoding,
4 => $type,
5 => true, //isStringAttachment
6 => $disposition,
7 => 0,
];
} catch (Exception $exc) {
$this->setError($exc->getMessage());
$this->edebug($exc->getMessage());
if ($this->exceptions) {
throw $exc;
}
return false;
}
return true;
}