WombaT
WombaT

Reputation: 800

PHP imap and folder name with space

How to handle folder names which contains spaces?

In every function which requires folder name, im using string like that:

{server.address.com:port}"INBOX.abc def"

but it causes php to crash with:

Can't subscribe to mailbox "INBOX.abc def": no such mailbox

changing string to look like this:

{server.address.com:port}INBOX."abc def"

doesnt change anything, still error. How can i open/check/whatever folder with space in name?

Edit: Question updated with a bit better error message

Combinations of folder strings which i tried:

Upvotes: 3

Views: 2725

Answers (3)

user1514290
user1514290

Reputation: 41

"\INBOX\abc def" this is better but maybe your INBOX in in the wrong place!
It must be in the "htdocs" i think!
and you can acces only a file, not a folder!
like: "\INBOX\abc def\file.txt"

Upvotes: 0

WombaT
WombaT

Reputation: 800

Solved!

According to RFC3501, Mailbox Naming (5.1):

Any character which is one of the atom-specials (see the Formal Syntax) will require that the mailbox name be represented as a quoted string or literal.

That includes space:

atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards / quoted-specials / resp-specials

so, the right folder string should be:

{server}"INBOX.folder with spaces"

but in my case, correct string is.....

{server}INBOX.folder with spaces

Dont know why, seems that PHPs imap functions are not fully compatible with RFC. Or just i cant read and understand rfc.

Upvotes: 2

user1514290
user1514290

Reputation: 41

You can try this sintax when you refer the directory: "\INBOX\folder with spaces"

So this solution gets "works on my machine" certificate. What error code do you get?

Upvotes: 1

Related Questions