public function PHPMailer::AddAttachment in SMTP Authentication Support 7.2
Same name and namespace in other branches
- 5 smtp.module \PHPMailer::AddAttachment()
- 7 smtp.phpmailer.inc \PHPMailer::AddAttachment()
Adds an attachment from a path on the filesystem. Returns FALSE if the file could not be found or accessed.
Parameters
string $path Path to the attachment.:
string $name Overrides the attachment name.:
string $encoding File encoding (see $Encoding).:
string $type File extension (MIME) type.:
Return value
bool
File
- ./
smtp.phpmailer.inc, line 1309 - 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
public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
try {
if (!@is_file($path)) {
throw new phpmailerException(t('Could not access file: !nofile', array(
'!nofile' => $path,
)), self::STOP_CONTINUE);
}
$filename = basename($path);
if ($name == '') {
$name = $filename;
}
$this->attachment[] = array(
0 => $path,
1 => $filename,
2 => $name,
3 => $encoding,
4 => $type,
5 => FALSE,
// isStringAttachment
6 => 'attachment',
7 => 0,
);
} catch (phpmailerException $e) {
$this
->SetError($e
->getMessage());
if ($this->exceptions) {
throw $e;
}
if ($this->logging) {
watchdog_exception('smtp', $e);
}
if ($e
->getCode() == self::STOP_CRITICAL) {
return FALSE;
}
}
return TRUE;
}