0

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?

Zingerale
  • 1
  • 3
  • Yes, there is such a way: RFC6154 – arnt Mar 05 '15 at 13:08
  • What about email clients that don't support RFC6154? – Zingerale Mar 05 '15 at 17:39
  • Won't find those mailboxes. And mail clients that don't support IMAP won't even be able to connect to the IMAP server. – arnt Mar 05 '15 at 17:44
  • Can you give me a code example of how to get these special-use mailboxes using the php imap functions? – Zingerale Mar 06 '15 at 09:54
  • No, I cannot. That's why I posted a comment, not an answer. But the library you use is open source, so you can add 6154 support. That's how open source gets improved, after all. – arnt Mar 06 '15 at 13:14

2 Answers2

0

Maybe you should have check the number of messages in each folder? Usually working Trash or Sent box contain messages.

Mitrohin
  • 1
  • 2
  • I still need to get the box even if they have no messages. After I get the box, it will synchronize with the server. Not being able to identify the boxes is a problem when, for example, I delete a message from the application. Since I don't know which of those boxes is the Trash box, I don't know where to send the deleted message. – Zingerale Mar 05 '15 at 12:56
  • Try to look at the message header. Or allow the user to choose the folders. – Mitrohin Mar 05 '15 at 13:08
  • You're saying there is no way to identify a box via code? – Zingerale Mar 05 '15 at 15:50
0

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.

Zingerale
  • 1
  • 3