Sempre class.phpmailer.php:

Codice PHP:
    /**
     * Returns the start of a message boundary.
     * @access private
     */
    
function GetBoundary($boundary$charSet$contentType$encoding) {
        
$result "";
        if(
$charSet == "") { $charSet $this->CharSet; }
        if(
$contentType == "") { $contentType $this->ContentType; }
        if(
$encoding == "") { $encoding $this->Encoding; }

        
$result .= $this->TextLine("--" $boundary);
        
$result .= sprintf("Content-Type: %s; charset = \"%s\""
                            
$contentType$charSet);
        
$result .= $this->LE;
        
$result .= $this->HeaderLine("Content-Transfer-Encoding"$encoding);
        
$result .= $this->LE;
       
        return 
$result;
    }
    
    
/**
     * Returns the end of a message boundary.
     * @access private
     */
    
function EndBoundary($boundary) {
        return 
$this->LE "--" $boundary "--" $this->LE
    }
    
    
/**
     * Sets the message type.
     * @access private
     * @return void
     */
    
function SetMessageType() {
        if(
count($this->attachment) < && strlen($this->AltBody) < 1)
            
$this->message_type "plain";
        else
        {
            if(
count($this->attachment) > 0)
                
$this->message_type "attachments";
            if(
strlen($this->AltBody) > && count($this->attachment) < 1)
                
$this->message_type "alt";
            if(
strlen($this->AltBody) > && count($this->attachment) > 0)
                
$this->message_type "alt_attachments";
        }
    }

    
/**
     * Returns a formatted header line.
     * @access private
     * @return string
     */
    
function HeaderLine($name$value) {
        return 
$name ": " $value $this->LE;
    }

    
/**
     * Returns a formatted mail line.
     * @access private
     * @return string
     */
    
function TextLine($value) {
        return 
$value $this->LE;
    }

    
/////////////////////////////////////////////////
    // ATTACHMENT METHODS
    /////////////////////////////////////////////////

    /**
     * Adds an attachment from a path on the filesystem.
     * Returns false if the file could not be found
     * or accessed.
     * @param string $path Path to the attachment.
     * @param string $name Overrides the attachment name.
     * @param string $encoding File encoding (see $Encoding).
     * @param string $type File extension (MIME) type.
     * @return bool
     */
    
function AddAttachment($path$name ""$encoding "base64"
                           
$type "application/octet-stream") {
        if(!@
is_file($path))
        {
            
$this->SetError($this->Lang("file_access") . $path);
            return 
false;
        }

        
$filename basename($path);
        if(
$name == "")
            
$name $filename;

        
$cur count($this->attachment);
        
$this->attachment[$cur][0] = $path;
        
$this->attachment[$cur][1] = $filename;
        
$this->attachment[$cur][2] = $name;
        
$this->attachment[$cur][3] = $encoding;
        
$this->attachment[$cur][4] = $type;
        
$this->attachment[$cur][5] = false// isStringAttachment
        
$this->attachment[$cur][6] = "attachment";
        
$this->attachment[$cur][7] = 0;

        return 
true;
    }

    
/**
     * Attaches all fs, string, and binary attachments to the message.
     * Returns an empty string on failure.
     * @access private
     * @return string
     */
    
function AttachAll() {
        
// Return text of body
        
$mime = array();

        
// Add all attachments
        
for($i 0$i count($this->attachment); $i++)
        {
            
// Check for string attachment
            
$bString $this->attachment[$i][5];
            if (
$bString)
                
$string $this->attachment[$i][0];
            else
                
$path $this->attachment[$i][0];

            
$filename    $this->attachment[$i][1];
            
$name        $this->attachment[$i][2];
            
$encoding    $this->attachment[$i][3];
            
$type        $this->attachment[$i][4];
            
$disposition $this->attachment[$i][6];
            
$cid         $this->attachment[$i][7];
            
            
$mime[] = sprintf("--%s%s"$this->boundary[1], $this->LE);
            
$mime[] = sprintf("Content-Type: %s; name=\"%s\"%s"$type$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$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);
    }
    
    
/**
     * Encodes attachment in requested format.  Returns an
     * empty string on failure.
     * @access private
     * @return string
     */
    
function EncodeFile ($path$encoding "base64") {
        if(!@
$fd fopen($path"rb"))
        {
            
$this->SetError($this->Lang("file_open") . $path);
            return 
"";
        }
        
$file_buffer fread($fdfilesize($path));
        
$file_buffer $this->EncodeString($file_buffer$encoding);
        
fclose($fd);

        return 
$file_buffer;
    }