CodeIgniter Forums
Help with email attachment filename - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Help with email attachment filename (/showthread.php?tid=24197)



Help with email attachment filename - El Forum - 11-02-2009

[eluser]Unknown[/eluser]
Hi Guys,

I have a program where a user can email someone. This user can be able to save(draft) their message for future sending. My problem is how can I send the email attachments with the correct filename? The correct filename is stored on the database. The filename I used to store their file is generated random string.

$filename = $this->model->the_correct_filename_stored_on_the_database();

$this->email->attach('/path/to/generated_random_string'); //here I want to use the correct filename to be used as its attachment


Anyone pls?
Thanks in advance..


Help with email attachment filename - El Forum - 11-03-2009

[eluser]pistolPete[/eluser]
Please use [ code ] tags!

I once created an extension of the email ibrary: http://ellislab.com/forums/viewreply/564654/
It allows you to attach a "virtual" file.

In your case you could use:

Code:
$filename = $this->model->the_correct_filename_stored_on_the_database();
$file_contents = file_get_contents('/path/to/generated_random_string');
$this->email->attach($filename, 'attachment', $file_contents );