how to read latest mail from gmail using imap in php
<p>I want to read the latest mail from gmail having all replies in 1 mail. I am having a mail like,</p>

<pre><code>a5ew4rf564w56456sda4fe4ar

    On Fri, Mar 30, 2012 at 3:17 AM, DEMO &lt;demo@example.com&gt; wrote:

        54545646598789465489+


        On Fri, Mar 30, 2012 at 3:17 AM, DEMO &lt;demo@example.com&gt; wrote:

            jwehriuhwekmwjed


            On Fri, Mar 30, 2012 at 3:17 AM, DEMO &lt;demo@example.com&gt; wrote:

                sadjfksaef

                On Fri, Mar 30, 2012 at 3:16 AM, DEMO &lt;demo@example.com&gt; wrote:

                    he!!

                    On Fri, Mar 30, 2012 at 3:13 AM, Nobody &lt;nobody@host.example.com&gt; wrote:

                        rohan@walkover.in

                        new message from sales


                    -- 
                    Thanks &amp; Regards
                    ABC


                -- 
                Thanks &amp; Regards
                ABC


            -- 
            Thanks &amp; Regards
            ABC

        -- 
        Thanks &amp; Regards
        ABC


    -- 
    Thanks &amp; Regards
    ABC
</code></pre>

<p>Then I want only the last mail which is <code>a5ew4rf564w56456sda4fe4ar</code> sent by demo I used <code>imap_fetchbody</code> which gives the whole mail according to the <code>uid</code>. So How Can I fetch the last mail.</p>
