この質問は以前に提起されましたが、ユーザーは完全な解決策を提供しなかったため、他の誰かが助けてくれるかどうか疑問に思っていましたか?
スクリプトがメールボックスから読み取っている電子メール メッセージの一部である添付ファイルの MIME タイプを取得できる必要があります。
以下のコードは正常に動作しています。問題は、実行する必要があるサーバーを (まだ) PHP 5.3.6 にアップグレードできないため、同等または別の回避策が必要です。
$attachments = Array();
for ($j=0;$j<sizeof($selectBoxDisplay);$j++)
{
$attachments["emailedDocument".$j]["name"] = $selectBoxDisplay[$j];
$attachments["emailedDocument".$j]["content"] = imap_base64(imap_fetchbody($mbox,$msgno,$j+2));
$mime_headers = imap_fetchmime($mbox,$msgno,$j+2);
$contenttype = "Content-Type: ";
$contenttypepos = strpos($mime_headers, $contenttype);
$semicolon = strpos($mime_headers, ";");
$attachments["emailedDocument".$j]["type"] = substr($mime_headers, $contenttypepos + strlen($contenttype), $semicolon - strlen($contenttype));
// attachment filesize is the number of bytes in the content string
$attachments["emailedDocument".$j]["size"] = strlen($attachments["emailedDocument".$j]["content"]);
}
私はしばらくGoogleを検索しましたが、実際には何も思い浮かびませんでした.