Fetch Unsubscribe mail list scan it and remove / ignore
<p>I am doing a mail fetching website which will fetch the unsubscribed mailing list from gmail,yahoo.hotmail,aol. User will log in and put their mail id and then scan will appear to check how many unsubscription mailing list are there.Now user can remove those mailing list or ignore it. If unsubscription link need any popup window or another page to unsubscribe then in my website there will be a link to delete it after scanning of the mail. (Sometimes unsubscription is done automatically ). Here is my code to extract the email header only but i dont know how to determine the unsubscription mail and then my next operation .Please help me out from this situation as I am googling throughout the whole day. I have removed my username password from email.</p>

<p>copywindow.addEvent('domready',function() 
{
    var togglers = $$('div.toggler');</p>

<pre><code>if(togglers.length) 

    var gmail = new Fx.Accordion(togglers,$$('div.body'));

    togglers.addEvent('click',function() 
    { 
        this.addClass('read').removeClass('unread'); });

        togglers[0].fireEvent('click'); //first one starts out read
</code></pre>

<p>});
    $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
    $username = 'www@example.com';
    $password = 'password';</p>

<pre><code>$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());

$emails = imap_search($inbox,'ALL');

if($emails) {

  $output = '';

  rsort($emails);


  foreach($emails as $email_number) {

    $overview = imap_fetch_overview($inbox,$email_number,0);
    $message = imap_fetchbody($inbox,$email_number,2);

                       //this is my code to fetch the unsubscription mail list, but does not work
        $fwd = strpos($overview[0]-&gt;subject,'Fwd:');
        $cc = strpos($overview[0]-&gt;subject,'Cc:');
        $bcc = strpos($overview[0]-&gt;subject,'Bcc:');
        $re = strpos($overview[0]-&gt;subject,'Re:');


            $output.= '&lt;div class="toggler"&gt;';
            $output.= '&lt;span class="subject"&gt;'.$overview[0]-&gt;subject.'&lt;/span&gt;';
            $output.= '&lt;/div&gt;&lt;br&gt;';


  }
        echo $output;
} 

imap_close($inbox);
</code></pre>
