We help IT Professionals succeed at work.
Get Started

The following PHP_IMAP script is echoing an error; how do I hide the error from showing?

jvutechnc
jvutechnc asked
on
2,583 Views
Last Modified: 2013-11-10
The error messages are expected because my mailbox is empty, but I don't want them to show up.

Notice: Unknown: Mailbox is empty (errflg=1) in Unknown on line 0
Notice: Unknown: Sequence out of range (errflg=2) in Unknown on line 0

Thank you!!
<?php
include("dbconnect.php");
function translate_object($obj){
 return $obj->mailbox.'@'.$obj->host;

}



/* connect to server */
	$hostname = '{10.2.1.248:995/pop3/ssl/novalidate-cert}INBOX';
	$username = 'xxxxxx';
	$password = 'xxxxxx';

/* try to connect */
	$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to server: ' . imap_last_error());

/* grab emails */
	$emails = imap_search($inbox,'ALL');

	$headers = imap_headers($inbox);
	
	$numEmails = sizeof($headers);

	for($i = 1; $i < $numEmails+1; $i++)

	{

$mailHeader = @imap_headerinfo($inbox, $i);

$from = $mailHeader->reply_toaddress;

$subject = strip_tags($mailHeader->subject);

$body = htmlentities(imap_body($inbox, $i));

$date = $mailHeader->date;

$rows = "SELECT * FROM requests";
$result = mysql_query($rows);
$num=mysql_numrows($result);

$query = "INSERT INTO requests (`date`, `from`, `subject`, `message`) VALUES ('".date("D d M H:i")."','$from', '$subject', '".mysql_real_escape_string($body)."')";


	} 

imap_delete($inbox,'1:*');
imap_expunge($inbox);



/* close the connection */
	imap_close($inbox);

?>

Open in new window

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE