0

I have a mailbox (in French) with the following structure:

me@example.com
|
|_Inbox
|_Brouillons (="Drafts")
|_Éléments envoyés (="Sent items")
|_Éléments supprimés (="Deleted items")

My users usually check their emails with a webmail or a mail client. But sometimes I need to add messages manually in the "Sent" folder, which has the name Éléments envoyés, containing several accents and a whitespace.

Here is the relevant PHP code:

$imap_stream = imap_open("{imap.example.com:143/tls}", "me@example.com", "password");
imap_append($imap_stream, "{imap.example.com:143/tls}Éléments envoyés",
...

The above code does not work. If I try with a folder without accents, like Brouillons, the messages are correctly copied.

Could it be an encoding problem? If I check the properties with Thunderbird, the location is shown as

imap://me%40example.com@imap.example.com/%26AMk-l%26AOk-ments%20envoy%26AOk-s

Thanks in advance!

Andreas Schwarz
  • 1,788
  • 17
  • 42

1 Answers1

2

Thanks to Max's comment, I knew what to look for, and I found beetstra's answer.

The solution is then:

$utf7_folder_name = mb_convert_encoding("Éléments envoyés", "UTF7-IMAP", "UTF-8");
$imap_stream = imap_open("{imap.example.com:143/tls}", "me@example.com", "password");
imap_append($imap_stream, "{imap.example.com:143/tls}".$utf7_folder_name,
...
Community
  • 1
  • 1
Andreas Schwarz
  • 1,788
  • 17
  • 42