Hi Everyone,
How can I add a temporary file as an attachment to an email.
I am working on a plugin which create a temporary zip file containing ElggFile. How can I send the temporary zip file as attachement to an email.
The temporary zip file exists and contains all the ElggFile.
Here is my sample code.
$params['attachments'][] = [ 'filepath' => '<the temporary file path of the zip>', // i.e : /temp/download_I6jYwg.zip ];
notify_user($to_guid, $from_guid, $subject, $body, $params, ['email']);
The email is send but the attachment is not send.
Could someone help me ?
Regards,
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Jerome Bakker@jeabakker
Jerome Bakker - 1 like
- Hermand Pessek@rheman
Hermand Pessek - 0 likes
You must log in to post replies.Your solution should work.
Keep in mind that depending on how you create the temp file within PHP if you close the filehandler the file is removed.
You could also provide the ElggFile to the attachments array, or provide an array with 'contents' which is the content of the (temp) zipfile.
See https://github.com/Elgg/Elgg/blob/52a0189a68205290cfac02b13d7ab65ab26e72a4/engine/classes/Elgg/Email/Attachment.php#L23-L39
Thanks a lot it works