title: Getting bounced email. Error in the script
body: <p>I am trying to get bounced mail checking the body of the messages, but for some reason the script does nothing. </p>
  
  <p>I checked all the documentation on the subject and searched for a solution but couldn't find anything. </p>
  
  <p>I am sure some of you will be able to detect what I am doing wrong.</p>
  
  <p>Here is the relevant part of the code.</p>
  
  <pre><code>error_reporting( E_ALL ) ;
  
  $POP3Box = imap_open( "{" . $Domain . ":110/pop3/novalidate-cert", $EmailBox, $EmailPass ) ;
  
  if ( !$POP3Box ) :
    echo '&lt;br /&gt;&lt;div class="ErrorMessage"&gt; Connection failed!&lt;br /&gt; Wrong Email address or Password! Please check and try again...&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;' ;
    die ;
  endif ;
  
  $MessageQty = imap_num_msg( $POP3Box ) ;
  echo 'Total messages in "' . $EmailBox . '" = ' . $MessageQty . '&lt;br /&gt;&lt;br /&gt;' ;
  $MailNum = 1 ;
  $MailOrder = 1 ;
  
  while ( $MailNum &lt;= $MessageQty ) {// GET MESSAGES
    $EmailBody = imap_fetchbody( $POP3Box, $MailNum, 1 ) ;
  
    if ( strrpos( $EmailBody, 'Undelivered Mail Returned to Sender' )) {
      imap_delete( $POP3Box, $MailNum ) ;
      $MailOrder++;
    }
    else {
      die ;
    }
    $MailNum++;
  }
  
  if ( $MailOrder &gt; 1 )
    imap_expunge( $POP3Box ) ;
  
  if ( $MailNum &gt; 1 ) {
    echo 'No bounced messages found!&lt;br /&gt;' ;
  }
  else {
    echo 'Empty mailbox!&lt;br /&gt;' ;
  }
  </code></pre>