title: Get 'To' field value from imap_headerinfo function or imap_search function
body: <p>I have following code to get the value from 'To', but the output is <strong>Array</strong></p>
  
  <pre><code>$header=imap_headerinfo($inbox,'18');
  echo $header-&gt;to;
  </code></pre>
  
  <p><strong>Second</strong>
  I use imap_search function to search through the email &amp; find the desired string in the email body. Now some of the email clients do use different body, so let's say for yahoo.
  The actual email in Outlook or any other client looks like this:</p>
  
  <pre><code>The mail system
  
  &lt;dkkfdjhfhjd@gmail.com&gt;: host gmail-smtp-in.l.google.com[173.194.77.26] said:
  550-5.1.1 The email account that you tried to reach does not exist. Please
  try 550-5.1.1 double-checking the recipient's email address for typos or
  550-5.1.1 unnecessary spaces. Learn more at 550 5.1.1
  http://support.google.com/mail/bin/answer.py?answer=6596
  c10si1356788oed.181 - gsmtp (in reply to RCPT TO command)
  </code></pre>
  
  <p>However when I try to print it by:</p>
  
  <pre><code>$message = imap_fetchbody($inbox,'18',1);
  echo $message;
  </code></pre>
  
  <p>It prints like this:</p>
  
  <pre><code>The mail system : host gmail-smtp-in.l.google.com[173.194.77.26] said: 550-5.1.1
  The email account that you tried to reach does not exist. Please try 550-5.1.1 
  double-checking the recipient's email address for typos or 550-5.1.1 unnecessary 
  spaces. Learn more at 550 5.1.1 http://support.google.com/mail/bin/answer.py?
  answer=6596c10si1356788oed.181 - gsmtp (in reply to RCPT TO command)
  </code></pre>
  
  <p>I cannot get the email address from this as well.
  Can anyone tell the decent method to get the email address of the users whose delivery got failed? From headers or anything else? I need it badly, can anyone help?</p>