dlo*_*dlo 33
$header = imap_headerinfo($imap_conn, $msgnum);
$fromaddr = $header->from[0]->mailbox . "@" . $header->from[0]->host;
Run Code Online (Sandbox Code Playgroud)
最坏的情况,您可以使用以下内容自行解析标头:
<?php
$headers=imap_fetchheader($imap, $msgid);
preg_match_all('/([^: ]+): (.+?(?:\r\n\s(?:.+?))*)\r\n/m', $headers, $matches);
?>
Run Code Online (Sandbox Code Playgroud)
$matches 将包含 3 个数组:
$matches[0] are the full-lines (such as "To: user@user.com\r\n")
$matches[1] will be the header (such as "To")
$matches[2] will be the value (user@user.com)
Run Code Online (Sandbox Code Playgroud)
来自:http://www.php.net/manual/en/function.imap-fetchheader.php#82339