When I try to create a folder whose name is seperated by spaces it only takes the first word and ignores the second one. How do I solve this? I am writing with php to a dovecot sever. The space seperator given by LIST is "/".
The Code:
private const NEWLINE = "\r\n";
private socket = fsockopen("ssl://testmail.com", 465, $errno, $errstr,
20);
$foldername = "Hello World"
function createFolder($socket, $foldername) {
fputs($socket, "A3 Create " . $foldername . self::NEWLINE)
return read($socket);}
function read($socket)
{
stream_set_timeout($socket, 30);
$lines = [];
while(\FALSE !== ($line = fgets($socket))) {
$lines[] = $line;
if (\FALSE !== strpos($line, 'BAD')) {
break;
}
if (\FALSE !== strpos($line, 'NO')) {
break;
}
if (\FALSE !== strpos($line, 'OK')) {
break;
}
if (\FALSE === strpos($line, 'OK')) {
continue;
}
}
return $lines;}
I have tried escaping strings and write it in a different way, but nothing seems to work. It does create a folder, but as mentioned above only with the first word. Server reply:
array(1) {[0]=>string(25) "A3 OK Create completed."}
edit: Here are some of the things I tried out, once by modifing the fputs and then while playing around with the string:
fputs($socket, "A3 Create " . \$foldername . self::NEWLINE) Result: HTTP ERROR 500
fputs($socket, "A3 Create " . '$foldername' . self::NEWLINE) Result: $foldername
fputs($socket, "A3 Create " . "$foldername" . self::NEWLINE) Result: Hello
fputs($socket, "A3 Create " . '\$foldername . self::NEWLINE) Result: \$foldername
fputs($socket, "A3 Create " . 'Hello' . 'World' . self::NEWLINE) Result: HelloWorld
fputs($socket, "A3 Create " . 'Hello ' . 'World' . self::NEWLINE) Result: Hello
fputs($socket, "A3 Create " . "Hello " . "World" . self::NEWLINE) Result: Hello
$foldername = "'Hello World'"; Result: 'Hello
$foldername = '"Hello World"'; Result: Hello
$foldername = 'Hello World'; Result: Hello
$foldername = "'Hello \ World'"; Result: 'Hello
$foldername = "<<<EOD Hello World EOD"; Result: <<<EOD
$foldername = '<<<EOD Hello World EOD'; Result: <<<EOD
$foldername = <<<EOD Hello World EOD; Result: Hello
$foldername = "%Hello World%"; Result: %Hello
$foldername = '%Hello World%'; Result: %Hello
$foldername = '\Hello World'; Result: \Hello
$foldername = "\Hello World"; Result: \Hello
This Works:
$foldername = '"Hello\\ World"';