webdevRefinery Forum: Connection string for imap_open - webdevRefinery Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Rate Topic: -----

User is offline isuru 

  • Group: Members
  • Posts: 18
  • Joined: 07-June 12
  • LocationColombo, Sri Lanka

Posted 11 August 2012 - 08:27 AM (#1)

Connection string for imap_open


I'm writing a PHP script which is supposed to connect to an Outlook email account, retrieve the attached images and display them on a page.

I'm using WAMP and I've set up a mail server using hMailServer with the help of this article and it works fine.

But when I try to connect to the mailbox through my PHP script, it throws the following error shown in the screenshot even though I have emails in my Outlook account's inbox.

Posted Image

This is the PHP code I've written so far.

$serverName = "{localhost/imap:143}INBOX";
$serverName = "{localhost/pop3:110}INBOX";

$userName = "isuru@localhost.localdomain";
$passWord = "paswrd";

$mbox = imap_open($serverName, $userName, $passWord);
if(!$mbox)
{
	echo "Could not open Mailbox";
}

if($hdr = imap_check($mbox))
{
	echo "Messages " . $hdr->Nmsgs . "\n\n<br><br>";
	$msgCount = $hdr->Nmsgs;
}
else
{
	echo "failed";
}


This is the information regarding the mail account.

Posted Image

Can anyone please tell me what I'm missing here and what changes should be done?

Thank you. :)
0


User is offline Lemon 

  • I have a dream...
  • Group: Members
  • Posts: 686
  • Joined: 24-February 11
  • Expertise:HTML,CSS,PHP,Javascript,Node.js,SQL

Posted 11 August 2012 - 01:11 PM (#2)

The second declaration of $serverName is setting you up to connect to a POP server, but you then use imap_open. First thing I'd suggest is removing or commenting out line 2 and see if it then connects to the IMAP mailbox properly rather than POP. Also, if your email client is configured to not leave any messages on the server, the POP will return 0 messages as it does not act as a live mailbox server.
Posted Image
In the end, it's not the years in your life that count. It's the life in your years
1


User is offline isuru 

  • Group: Members
  • Posts: 18
  • Joined: 07-June 12
  • LocationColombo, Sri Lanka

Posted 11 August 2012 - 05:49 PM (#3)

Thank you for the response. I commented out this line
$serverName = "{localhost/pop3:110}INBOX";
and now it doesn't show any error messages but still displays
Messages : 0
.
How can I check if my mail client(Microsoft Outlook 2007) is configured not to leave any messages on the server? And what do I have to change?
0


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services