protected function PHPMailer::encodeFile
Search API
5.x PHPMailer.php | protected PHPMailer::encodeFile($path, $encoding = self::ENCODING_BASE64) |
Encode a file attachment in requested format. Returns an empty string on failure.
Parameters
string $path The full path to the file:
string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable':
Return value
string
Throws
1 call to PHPMailer::encodeFile()
- PHPMailer::attachAll in inc/
PHPMailer/ src/ PHPMailer.php - Attach all file, string, and binary attachments to the message. Returns an empty string on failure.
File
- inc/
PHPMailer/ src/ PHPMailer.php, line 3028
Class
- PHPMailer
- PHPMailer - PHP email creation and transport class.
Namespace
PHPMailer\PHPMailerCode
protected function encodeFile($path, $encoding = self::ENCODING_BASE64)
{
try {
if (!static::isPermittedPath($path) || !file_exists($path)) {
throw new Exception($this->lang('file_open') . $path, self::STOP_CONTINUE);
}
$file_buffer = file_get_contents($path);
if (false === $file_buffer) {
throw new Exception($this->lang('file_open') . $path, self::STOP_CONTINUE);
}
$file_buffer = $this->encodeString($file_buffer, $encoding);
return $file_buffer;
}
catch (Exception $exc) {
$this->setError($exc->getMessage());
return '';
}
}