Welcome Guest, Not a member yet? Register   Sign In
Wrong attachment name when sending with Email class
#1

[eluser]mDonchev[/eluser]
Hi Guys,

I have a problem sending email with attachments.

When I make this in the controler:
Code:
$this->email->attach($_FILES["doc1"]["tmp_name"],$_FILES["doc1"]["name"]);

I get the email, and there is an attachment, but instead of the real filename, the attachment is displayed with the tmp_name of the attached file.

Can you give me a hand and tell me what I do wrong to get the real filename as a name of the attachment?

Thanks in advance
Martin
#2

[eluser]rogierb[/eluser]
The second parameter is not for a name, but for the disposition.

If you want to use a different filename,you have to extend the email class like this:
Code:
function attach($file, $filename, $disposition = 'attachment')
    {
        $this->_attach_name[] = $filename;
        $this->_attach_file[] = $file;
        $this->_attach_type[] = $this->_mime_types(next(explode('.', basename($file))));
        $this->_attach_disp[] = $disposition; // Can also be 'inline'  Not sure if it matters
    }

and in the _built_message:
Code:
$filename = $this->_attach_file[$i];
$filename_send = $this->_attach_name[$i];
$basename = basename($filename_send);

That should do the trick.




Theme © iAndrew 2016 - Forum software by © MyBB