如何处理包含空格的文件夹名称?
在每个需要文件夹名称的函数中,我都使用这样的字符串:
{server.address.com:port}"INBOX.abc def"
但它会导致 php 崩溃:
Can't subscribe to mailbox "INBOX.abc def": no such mailbox
将字符串改成这样:
{server.address.com:port}INBOX."abc def"
没有改变任何东西,仍然是错误。我如何打开/检查/任何名称中有空格的文件夹?
编辑: 问题更新了更好的错误消息
我试过的文件夹字符串的组合:
- "INBOX.abc def"- 失败,
- INBOX."abc def"- 失败,
- \INBOX\abc def - 失败,
- "\INBOX\abc def"- 失败
最佳答案
解决了!
根据 RFC3501,邮箱命名 (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.
包括空间:
atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards / quoted-specials / resp-specials
所以,正确的文件夹字符串应该是:
{server}"INBOX.folder with spaces"
但在我的例子中,正确的字符串是......
{server}INBOX.folder with spaces
不知道为什么,PHP 的imap 函数似乎与RFC 不完全兼容。或者只是我无法阅读和理解 rfc。
关于带空格的PHP imap和文件夹名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11451986/