private function PHPMailer::EncodeFile in SMTP Authentication Support 7
Same name and namespace in other branches
- 5 smtp.module \PHPMailer::EncodeFile()
- 7.2 smtp.phpmailer.inc \PHPMailer::EncodeFile()
Encodes attachment in requested format. Returns an empty string on failure.
@access private
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
See also
EncodeFile()
1 call to PHPMailer::EncodeFile()
- PHPMailer::AttachAll in ./
smtp.phpmailer.inc - Attaches all fs, string, and binary attachments to the message. Returns an empty string on failure. @access private
File
- ./
smtp.phpmailer.inc, line 1447 - The mail handler class in smtp module, based on code of the phpmailer library, customized and relicensed to GPLv2.
Class
- PHPMailer
- PHPMailer - PHP email transport class NOTE: Requires PHP version 5 or later @package PHPMailer @author Andy Prevost @author Marcus Bointon @copyright 2004 - 2009 Andy Prevost
Code
private function EncodeFile($path, $encoding = 'base64') {
try {
if (!is_readable($path)) {
throw new phpmailerException(t('File Error: Could not open file: !nofile', array(
'!nofile' => $path,
)), self::STOP_CONTINUE);
}
if (function_exists('get_magic_quotes')) {
function get_magic_quotes() {
return FALSE;
}
}
$magic_quotes = get_magic_quotes_runtime();
if ($magic_quotes) {
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
set_magic_quotes_runtime(0);
}
else {
ini_set('magic_quotes_runtime', 0);
}
}
$file_buffer = file_get_contents($path);
$file_buffer = $this
->EncodeString($file_buffer, $encoding);
if ($magic_quotes) {
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
set_magic_quotes_runtime($magic_quotes);
}
else {
ini_set('magic_quotes_runtime', $magic_quotes);
}
}
return $file_buffer;
} catch (Exception $e) {
$this
->SetError($e
->getMessage());
return '';
}
}