[eluser]Unknown[/eluser]
hi
just added this feature to
the email library,
it consists to give a
alternate name to the email attachement.
the goal :
sometimes, the file uploaded is named like
201110_abcdefrlflfk.doc but we want that when we send it as an attachement to see
your_file.doc, it is better for reading and makes more sens,
so here is the changes in
email.php library :
Code:
public function attach($filename, $disposition = 'attachment',$altName=null)
{
$this->_attach_name[] = $filename;
$this->_attach_type[] = $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION));
// if altname provided then put it as an alternate name for the attachment if not provided then give it the filename.
$this->_attach_altname[] = ($altName) ? $altName:basename($filename);
$this->_attach_disp[] = $disposition; // Can also be 'inline' Not sure if it matters
return $this;
}
in the
_build_message function :
Code:
$filename = $this->_attach_name[$i];
$basename = basename($filename);
$altname=$this->_attach_altname[$i];
$ctype = $this->_attach_type[$i];
if ( ! file_exists($filename))
{
$this->_set_error_message('lang:email_attachment_missing', $filename);
return FALSE;
}
$h = "--".$this->_atc_boundary.$this->newline;
$h .= "Content-type: ".$ctype."; ";
$h .= "name=\"".$altname."\"".$this->newline;
$h .= "Content-Disposition: ".$this->_attach_disp[$i].";".$this->newline;
$h .= "Content-Transfer-Encoding: base64".$this->newline;
and for the
Clear function :
Code:
if ($clear_attachments !== FALSE)
{
$this->_attach_name = array();
$this->_attach_type = array();
$this->_attach_disp = array();
$this->_attach_altname= array();
}