• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Replicate PHPMailer rename attachment functionality

#1
[eluser]SBH[/eluser]
I'm trying to edit Email.php to add the ability to rename attachments during the $this->email->attach() call. I don't think I understand _build_message well enough or even really know if this is the correct method to go about this.

Code:
for ($i=0; $i < count($this->_attach_name); $i++)
        {
            $filename = $this->_attach_name[$i];
            $basename = basename($filename);
            $ctype = $this->_attach_type[$i];

            if ( ! file_exists($filename))
            {
                $this->_set_error_message('email_attachment_missing', $filename);
                return FALSE;
            }    

            $h  = "--".$this->_atc_boundary.$this->newline;
            $h .= "Content-type: ".$ctype."; ";
            $h .= "name=\"".$basename."\"".$this->newline;
            $h .= "Content-Disposition: ".$this->_attach_disp[$i].";".$this->newline;
            $h .= "Content-Transfer-Encoding: base64".$this->newline;

            $attachment[$z++] = $h;
            $file = filesize($filename) +1;
    
            if ( ! $fp = fopen($filename, FOPEN_READ))
            {
                $this->_set_error_message('email_attachment_unreadable', $filename);
                return FALSE;
            }
    
            $attachment[$z++] = chunk_split(base64_encode(fread($fp, $file)));
            fclose($fp);
        }



Is this the only line I have to change? :

Code:
$h .= "name=\"".$basename."\"".$this->newline;

I don't understand exactly how the attachment is happening and the base_64 splitting. Any help would be greatly appreciated. Thank you!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.