phpgmailimapimap-open

PHP IMAP - Can't identify boxes


I'm creating a PHP application to save in my database all the email messages from an email account.

When I connect to a gmail account and use the imap_list() function, I get these boxes:

 array {
[0]=> "{imap.gmail.com:993/ssl}INBOX"
[1]=> "{imap.gmail.com:993/ssl}[Gmail]/Caixote do Lixo"
[2]=> "{imap.gmail.com:993/ssl}[Gmail]/Com estrela"
[3]=> "{imap.gmail.com:993/ssl}[Gmail]/Correio enviado"
[4]=> "{imap.gmail.com:993/ssl}[Gmail]/Importante"
[5]=> "{imap.gmail.com:993/ssl}[Gmail]/Rascunhos"
[6]=> "{imap.gmail.com:993/ssl}[Gmail]/Spam"
[7]=> "{imap.gmail.com:993/ssl}[Gmail]/Todo o correio" }

These boxes are in Portuguese. When I connect to a different account, the boxes have English names. This mean I have no means to know which one of the boxes is the Trash box, or Sent box, for example.

Is there a way to identify each box correctly?


Solution

  • This problem is a bit tricky. I solved this by connecting to the imap client by using a socket connection instead of using the PHP native imap functions. This way I get the special-use attributes I need.