CodeIgniter Forums
Codeigniter Email Attachment name not support Unicode? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Codeigniter Email Attachment name not support Unicode? (/showthread.php?tid=70169)



Codeigniter Email Attachment name not support Unicode? - squashking - 03-03-2018

Hi, I tried sending an attachment containing Unicode characters, and the attachment was  sent successfully. But the Unicode characters were removed from the file name. For example, if I send an attachment named "你好.jpg", then the receiver will receive the file but it's named ".jpg" (unicode characters are removed). I want to keep the original attachment name, is there any solution? Thank you very much!

Code:
$this->email->attach("path/to/你好.jpg"); //attachment name contains Unicode characters



RE: Codeigniter Email Attachment name not support Unicode? - InsiteFX - 03-04-2018

This may help you understand what is going on.

Filesystem encoding and PHP


RE: Codeigniter Email Attachment name not support Unicode? - squashking - 03-04-2018

(03-04-2018, 05:09 AM)InsiteFX Wrote: This may help you understand what is going on.

Filesystem encoding and PHP

Thank you, is there any solution if I want to use Unicode file name? It does not make sense the file name cannot use Unicode characters.


RE: Codeigniter Email Attachment name not support Unicode? - InsiteFX - 03-05-2018

I think they said that the new international php 7+ should work now,
not sure so you would need to check php.net


RE: Codeigniter Email Attachment name not support Unicode? - squashking - 03-05-2018

(03-05-2018, 04:03 AM)InsiteFX Wrote: I think they said that the new international php 7+ should work now,
not sure so you would need to check php.net

Thank you. I believe there should be other solutions instead of upgrading PHP version. After all, having Unicode file name is very common and is very necessary in many cases.


RE: Codeigniter Email Attachment name not support Unicode? - Narf - 03-09-2018

(03-05-2018, 04:32 AM)squashking Wrote:
(03-05-2018, 04:03 AM)InsiteFX Wrote: I think they said that the new international php 7+ should work now,
not sure so you would need to check php.net

Thank you. I believe there should be other solutions instead of upgrading PHP version. After all, having Unicode file name is very common and is very necessary in many cases.

Actually, if that was the problem, you wouldn't just have stripped unicode characters from the filename; you'd have no attachment at all. Please test and tell me if this works (so I can merge it into the main code tree): https://github.com/bcit-ci/CodeIgniter/commit/ea85f732beec4356baecf4c0d8606f1738c5b569

BUT! Do your PHP upgrade, ASAP. Don't look for excuses to avoid it.
PHP 5 is no longer supported and only 5.6 is receiving security patches until the end of this year, and that's on par with 7.0!

https://secure.php.net/supported-versions.php

Yes, even PHP 7.0 is old news now. Don't delay those upgrades, it doesn't do you any favors.


RE: Codeigniter Email Attachment name not support Unicode? - squashking - 03-16-2018

Thanks. I finally solved the problem, just by adding the 3rd parameter to $this->email->attach(para1, para2, para3). Set the 3rd parameter to the Unicode name it will work.