NB the message numbers start from 1 not 0 as normally used for iterating.
imap_body
(PHP 4, PHP 5)
imap_body — メッセージ本文を読む
説明
string imap_body
( resource $imap_stream
, int $msg_number
[, int $options = 0
] )
imap_body() は、現在のメールボックスにある msg_number 番目のメッセージの本文を返します。
imap_body() は、メッセージの本文と全く同じ コピーのみを返します。マルチパート MIME エンコードされたメッセージの 一部を展開するには、その構造を解析するために imap_fetch_structure() を使用し、単一の部分要素の コピーを展開する際には、 imap_fetchbody() を使用する必要があります。
パラメータ
- imap_stream
-
imap_open() が返す IMAP ストリーム。
- msg_number
-
メッセージ番号。
- options
-
オプションの options はビットマスクであり、 以下の要素の組み合わせとなります。
- FT_UID - msg_number は UID です
- FT_PEEK - 既に設定されていない場合、\Seen フラグを設定しない
- FT_INTERNAL - 内部フォーマットで文字列を返す。 CRLF に正規化しない。
返り値
指定したメッセージの本文を文字列で返します。
paddywwoof
26-Jan-2011 05:09
deenfirdoush at gmail dot com
14-Dec-2009 07:08
Simple example on how to read body message of the recent mail.
<?php
$imap = imap_open("{pop.example.com:995/pop3/ssl/novalidate-cert}", "username", "password");
if( $imap ) {
//Check no.of.msgs
$num = imap_num_msg($imap)
//if there is a message in your inbox
if( $num >0 ) {
//read that mail recently arrived
echo imap_qprint(imap_body($imap, $num));
}
//close the stream
imap_close($imap);
}
?>
