private function PHPMailer::AttachAll in SMTP Authentication Support 7
Same name and namespace in other branches
- 5 smtp.module \PHPMailer::AttachAll()
- 7.2 smtp.phpmailer.inc \PHPMailer::AttachAll()
Attaches all fs, string, and binary attachments to the message. Returns an empty string on failure. @access private
Return value
string
1 call to PHPMailer::AttachAll()
- PHPMailer::CreateBody in ./
smtp.phpmailer.inc - Assembles the message body. Returns an empty string on failure. @access public
File
- ./
smtp.phpmailer.inc, line 1371 - 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 AttachAll() {
// Return text of body
$mime = array();
$cidUniq = array();
$incl = array();
// Add all attachments
foreach ($this->attachment as $attachment) {
// Check for string attachment
$bString = $attachment[5];
if ($bString) {
$string = $attachment[0];
}
else {
$path = $attachment[0];
}
if (in_array($attachment[0], $incl)) {
continue;
}
$filename = $attachment[1];
$name = $attachment[2];
$encoding = $attachment[3];
$type = $attachment[4];
$disposition = $attachment[6];
$cid = $attachment[7];
$incl[] = $attachment[0];
if ($disposition == 'inline' && isset($cidUniq[$cid])) {
continue;
}
$cidUniq[$cid] = TRUE;
$mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
$mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this
->EncodeHeader($this
->SecureHeader($name)), $this->LE);
$mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
if ($disposition == 'inline') {
$mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
}
$mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this
->EncodeHeader($this
->SecureHeader($name)), $this->LE . $this->LE);
// Encode as string attachment
if ($bString) {
$mime[] = $this
->EncodeString($string, $encoding);
if ($this
->IsError()) {
return '';
}
$mime[] = $this->LE . $this->LE;
}
else {
$mime[] = $this
->EncodeFile($path, $encoding);
if ($this
->IsError()) {
return '';
}
$mime[] = $this->LE . $this->LE;
}
}
$mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
return join('', $mime);
}