Welcome Guest, Not a member yet? Register   Sign In
Email class tweak to allow nem attachment names
#1

[eluser]Unknown[/eluser]
Hello,

I had to do a little tweak to the Email class to allow me to set new filenames to the attachments. This allows me to store the file on the system with an encrypt name, but when I send an email with those files attached, they will be sent with the names I want to define.

New call of the email->attach() method:

Code:
$this->email->attach($system_path_to_file, $disposition, $filename_for_attachment);

Example of use:

Code:
$this->email->attach('/path/to/filename.pdf', '', 'client.pdf');

This will attach the file named 'filename.pdf' with the name 'client.pdf' on the email.

If no new filename is given, the attach method will work in the original way.

Example:

Code:
$this->email->attach('/path/to/filename.pdf');


This will attach the file named 'filename.pdf' with the name 'filename.pdf' on the email.

This did the trick for me!

Here is the final Email class I use in case you want to merge it to the CI Email class.

http://www.vtec.pt/code/Email.phps


Thanks,

Vasco Pinheiro




Theme © iAndrew 2016 - Forum software by © MyBB