PHP: Send email with attachment and UTF8 in filenames
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The PHP file has UTF-8 encoding. Note the utf8_decode of $attachment_filename. Without it all email clients get it wrong. With it, some get it right (like GMail) but other still get it wrong, or replaces the filename with some default name. Also, I can't understand why the utf8_decode helps at all.
Everything else except the filename of the attachment is fine. If the filename contains just regular ascii, there is no problem.
I tried to read about it in the Pear documentation:
Well that's simply incorrect. As I wrote, everything except the filename of the attachment is fine. Also I can send and receive emails with UTF8 in filenames just fine. I just don't know how to do it with PHP.
Without it all email clients get it wrong. With it, some get it right (like GMail) but other still get it wrong, or replaces the filename with some default name
Thanks. Good idea to check the source in the emails. The US_ASCII part seems incorrect, but I guess some email clients will understand that it's UTF-8 and some not?
I tried to use an email client called Firstclass that we use at work, and I sent an email to a guy who uses Outlook. Both got the filename in the attachment wrong. I'll try to investigate more on Monday when I'm at work. Did the strange letters look right with Thunderbird?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.