original names of attachments by IMAP fetching
Moderator: mkoch227
original names of attachments by IMAP fetching
Hello.
I have problems with the original names of attachments by IMAP fetching. By fetching an email with an attachment name not in English (in my case in Russian language) - the attachment in the ticket has an absolute different name.
I had this problem also by attaching files in replies in tickets (not by fetching), but i found this code and it helped me: http://srv.nsk.ru/support/knowledgebase.php?article=67
Can anybody help me please with the names of attachments by incomming emails? I need the original names of files in tickets.
I found this php file and i think it can be edited, maybe i'm wrong: pipe_functions.inc.php. Can anybody tell me what i must to edit to resolve my problem? Maybe can anybody send me the proper php files. I'm not a developer. Thank you!
I have problems with the original names of attachments by IMAP fetching. By fetching an email with an attachment name not in English (in my case in Russian language) - the attachment in the ticket has an absolute different name.
I had this problem also by attaching files in replies in tickets (not by fetching), but i found this code and it helped me: http://srv.nsk.ru/support/knowledgebase.php?article=67
Can anybody help me please with the names of attachments by incomming emails? I need the original names of files in tickets.
I found this php file and i think it can be edited, maybe i'm wrong: pipe_functions.inc.php. Can anybody tell me what i must to edit to resolve my problem? Maybe can anybody send me the proper php files. I'm not a developer. Thank you!
Re: original names of attachments by IMAP fetching
Hesk does that for security reasons as it can't properly check all situations for all encodings.
Can you send a sample email to pop3test AT hesk DOT com? I will have a look and see if there is a quick fix (it may take a while as I am super busy this week). If not, you will most likely need to hire a developer.
Can you send a sample email to pop3test AT hesk DOT com? I will have a look and see if there is a quick fix (it may take a while as I am super busy this week). If not, you will most likely need to hire a developer.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: original names of attachments by IMAP fetching
Klemen, thank you for answer!
I sended an email with two attachments.
The first one is an empty txt file with original name. The second in an png how the name see.
I sended an email with two attachments.
The first one is an empty txt file with original name. The second in an png how the name see.
Re: original names of attachments by IMAP fetching
If you change to in inc/pipe_functions.inc.php it works for your test.
However, please note that this is NOT fully tested and I take no responsibility for any misbehavior and I don't know how this will behave if your customers send emails not in utf-8 encoding. It also assumes you have PHP iconv function enabled on your server.
Code: Select all
$myatt['real_name'] = hesk_cleanFileName($v['orig_name']);
Code: Select all
$v['orig_name'] = hesk_encodeUTF8($v['orig_name'], $results['encoding']);
$myatt['real_name'] = hesk_htmlspecialchars($v['orig_name']);
However, please note that this is NOT fully tested and I take no responsibility for any misbehavior and I don't know how this will behave if your customers send emails not in utf-8 encoding. It also assumes you have PHP iconv function enabled on your server.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: original names of attachments by IMAP fetching
Klemen,
I changed the code in inc/pipe_functions.inc.php, but now i have other symbols in file names.
I use xampp, how i can enable the PHP iconv function? Can you please help. Google helped not
I changed the code in inc/pipe_functions.inc.php, but now i have other symbols in file names.
I use xampp, how i can enable the PHP iconv function? Can you please help. Google helped not

Re: original names of attachments by IMAP fetching
That probably means some encodings aren't properly parsed.
Open phpinfo.php in your browser (it's in the "read this before posting" thread) and search for iconv to see if it is enabled.
You can also try changing this in pipe_functions
to this and see if it makes any difference:
Or to:
If that doesn't work for NEW emails I would have to see a sample email that doesn't work (full email with headers).
Open phpinfo.php in your browser (it's in the "read this before posting" thread) and search for iconv to see if it is enabled.
You can also try changing this in pipe_functions
Code: Select all
return function_exists('iconv') ? iconv($encoding, 'UTF-8', $in) : utf8_encode($in);
Code: Select all
return mb_convert_encoding($in, 'UTF-8', $encoding);
Code: Select all
return mb_convert_encoding($in, 'UTF-8', mb_detect_encoding($str));
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: original names of attachments by IMAP fetching
Klemen,
changing to return mb_convert_encoding($in, 'UTF-8', $encoding); in pipe_functions helped me for recieving emails with right attachment names from a big mail service. I think they have utf-8 as default by sending emails. Almost all our customers are using Outlook and here by default sended emails are in KOI8-R, so the attachments have wrong names. If i change in Outlook the charset for sending emails to UTF-8 all attachments have the right name.
What can i change to recieve the right attachments names by using KOI8-R? It is impossible to say the customers to sending mails in utf-8.
by the way, the iconv is enabled. In all 3 lines local value and master value is empty.
changing to return mb_convert_encoding($in, 'UTF-8', $encoding); in pipe_functions helped me for recieving emails with right attachment names from a big mail service. I think they have utf-8 as default by sending emails. Almost all our customers are using Outlook and here by default sended emails are in KOI8-R, so the attachments have wrong names. If i change in Outlook the charset for sending emails to UTF-8 all attachments have the right name.
What can i change to recieve the right attachments names by using KOI8-R? It is impossible to say the customers to sending mails in utf-8.
by the way, the iconv is enabled. In all 3 lines local value and master value is empty.
Re: original names of attachments by IMAP fetching
Send a KOI8-R encoded email with attachments to my test address and I will check.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: original names of attachments by IMAP fetching
I sent an email with theme: KOI8-R email
Re: original names of attachments by IMAP fetching
Try uploading this to your "inc" folder and see if there is any difference:
https://hesk.com/extras/284_pipe_functions_name.zip
Note that I haven't been able to fully test it so please test using different emails yourself.
https://hesk.com/extras/284_pipe_functions_name.zip
Note that I haven't been able to fully test it so please test using different emails yourself.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: original names of attachments by IMAP fetching
Klemen,
Thank you very much for support! I'll change my answer a bit.
We asked our clients to send emails in utf-8. Now we have much more less problems with the attachment names. But there is just one moment. If the name of attachments have a comma (,) then the file fetched in hesk, lose all symbols in attachment name what follows next the comma. Is there anything we can do about it?
And one more question. Is it possible to fetch emails with attached .msg files? Its an Outlook email extension. Now they don't fall into hesk. I added this extension to allowed file types.
Thank you very much for support! I'll change my answer a bit.
We asked our clients to send emails in utf-8. Now we have much more less problems with the attachment names. But there is just one moment. If the name of attachments have a comma (,) then the file fetched in hesk, lose all symbols in attachment name what follows next the comma. Is there anything we can do about it?
And one more question. Is it possible to fetch emails with attached .msg files? Its an Outlook email extension. Now they don't fall into hesk. I added this extension to allowed file types.