Czy istnieje błąd w funkcji imap_fetch_overview () w PHP podczas odczytu nagłówków z nawiasami?
Wysyłam wiadomość e-mail w PHP za pomocą następującego kodu:
<?php
error_reporting(E_ALL);
# write mail
###############################################################################
$recipient = "[email protected]";
$subject = mb_encode_mimeheader("Subject äöü ");
$text = "Hallo";
$header = "From:".mb_encode_mimeheader("Name with [], ÄÖÜ and spaces")." <[email protected]>"
. "\r\n" . "Reply-To: [email protected]"
. "\r\n" . "X-Mailer: PHP/" . phpversion();
// send e-mail
mail($recipient, $subject, $text, $header);
?>
Następnie próbuję przeczytać e-mail za pomocąimap_fetch_overview()
w następującym kodzie:
<?php
# receive mails
###############################################################################
$mailbox = imap_open("{imap.server.tld/norsh}", "[email protected]", "********");
$MC = imap_check($mailbox);
$result = imap_fetch_overview($mailbox,"1:{$MC->Nmsgs}",0);
echo "<table>";
foreach ($result as $overview) {
echo "<tr>"
."<td>".$overview->msgno."</td>"
."<td>".$overview->uid."</td>"
."<td>".$overview->date."</td>"
."<td>".$overview->udate."</td>"
."<td>".$overview->from."</td>"
."<td>".$overview->to."</td>"
."<td>".$overview->size."</td>"
."<td>".$overview->subject."</td>"
."</tr>";
}
echo "</table>";
?>
Otrzymuję następujący błąd:
Notice: Undefined property: stdClass::$from in /mail_test.php on line 34
I$overview->from
nie ma wartości.
Gdy część „Od:” nie zawiera nawiasów, nie ma problemu.Czy muszę także zakodować nawiasy? W jaki sposób? myślałemmb_encode_mimeheader()
robi pracę.
EDYTOWAĆ:
Wynikvar_dump($overview)
jest:
object(stdClass)#18 (14) {
["subject"]=>
string(40) "Subject =?UTF-8?B?w4PCpMODwrzDg8K2IA==?="
["to"]=>
string(16) "[email protected]"
["date"]=>
string(31) "Thu, 16 Aug 2012 16:58:23 +0200"
["message_id"]=>
string(58) "<**************************************>"
["size"]=>
int(1585)
["uid"]=>
int(18)
["msgno"]=>
int(17)
["recent"]=>
int(1)
["flagged"]=>
int(0)
["answered"]=>
int(0)
["deleted"]=>
int(0)
["seen"]=>
int(0)
["draft"]=>
int(0)
["udate"]=>
int(1345129104)
}