Good evening everybody!
I’m stuck at writing my own email program in php for fun. I try to download all attachments from my email-address but some files have names like
ISO-8859-15”%46%6C%79%65%72%20%53%61%69%73%6F%6E%65%72%F6%66
To decode the headers is used this function:
private function imap_header_decode($text) {
$ret = "";
$elements = imap_mime_header_decode($text);
for($i = 0; $i < count($elements); $i++) {
$ret .= utf8_decode($elements[$i]->text);
}
return $ret;
}
The headers are getting correctly decrypted while the file names don’t. What could be the problem or better, how can I solve it?
EDIT: I used the imap_ functions from php for doing all the mail things (using pop3 with ssl)
This type of encoding is called url encoding and it is defined in RFC 3986 (“URI syntax”). You can decode it with
urldecode.