public function PHPMailer::addStringEmbeddedImage
Search API
5.x PHPMailer.php | public PHPMailer::addStringEmbeddedImage(
$string,
$cid,
$name = '',
$encoding = self::ENCODING_BASE64,
$type = '',
$disposition = 'inline'
) |
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.
Parameters
string $string The attachment binary data:
string $cid Content ID of the attachment; Use this to reference: the content when using an embedded image in HTML
string $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.
string $encoding File encoding (see $Encoding), defaults to 'base64':
string $type MIME type - will be used in preference to any automatically derived type:
string $disposition Disposition to use:
Return value
bool True on successfully adding an attachment
Throws
- PHPMailer::msgHTML in inc/
PHPMailer/ src/ PHPMailer.php - Create a message body from an HTML string. Automatically inlines images and creates a plain-text version by converting the HTML, overwriting any existing values in Body and AltBody. Do not source $message content from user input! $basedir is prepended…
File
- inc/
PHPMailer/ src/ PHPMailer.php, line 3468
Class
- PHPMailer
- PHPMailer - PHP email creation and transport class.
Namespace
PHPMailer\PHPMailerCode
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 and !empty($name)) {
$type = static::filenameToType($name);
}
if (!$this->validateEncoding($encoding)) {
throw new Exception($this->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;
}