PDA

View Full Version : Difficulty using PHP's IMAP functions


LWillmann
04-08-2004, 02:20 PM
I have a series of scripts designed for opening a user's email box and letting the user read email, compose and such. It's basically a PHP base mail program.

At one time, I had all of the mail, http, database functions running on a single linux box running Red Hat 6.1. I had compiled sendmail, apache, MySQL and PHP following the instructions. Everything worked fine with my email interface.

I moved the mail duties to it's own box to alleviate workload on the web server and now the scripts don't work.

I am using the correct name for the hose (not localhost), I have tried via both private and public IP as well and it just will not work.

This has to be a server config issue, since if I plug my ISPs mail server into the script along with my username and password it will open the email account. With the proper mail server info in it, it just reports that it failed to open the stream.

I can SSH to the web server and open a telnet connection to the mail server on port 110 (the port I'm using with the imap_open function) and it will let me log in to my mailbox on the server from telnet. There just seems to be something not letting PHP do it.

Does anyone have an idea where to look?

iDxMan
04-08-2004, 11:16 PM
I thought pop3 was on port 110 and imap was 143.....

Have you tried using another webmail program such as squirrelmail just to make sure its not your code?

-r

LWillmann
04-12-2004, 09:39 AM
PHP's imap functions will work with IMAP and POP3. I am attempting to use it with POP3. That's why I'm hitting port 110.

As for trying with another program, I've got about 30 people accessing their email on the mail server using Outlook and Outlook Express with POP3, and they're all running fine.

If I change the mail server name to be that of my ISP's mail server, and change the username and password to suit, I can access my ISP's email server with the code, so I know the code is good. It's GOT to be a server config issue, either on the web server or the mail server. I just haven't figured out which yet.

You, or anyone else, have any other ideas?

stuka
04-12-2004, 12:27 PM
Can you check the logs on the mail server to see if there are any error messages generated by your script?

iDxMan
04-13-2004, 10:06 AM
Any clues from imap_last_error() ?


$mbox = imap_open ("{new.pop3.host:110/pop3}INBOX", "user_id", "password");

if ( FALSE === $mbox ) {
exit ("Ahhhhhhhhhhhhh!: " . imap_last_error() ."\n");
}
else {
echo "Connected..";
}


-r

LWillmann
04-13-2004, 10:40 AM
Ok, looking at the log file, here is what I see after attempting to access the mailbox:

Apr 13 08:46:37 mail ipop3d[16237]: pop3 service init from 192.168.0.211
Apr 13 08:46:38 mail ipop3d[16237]: Command stream end of file while reading line user=??? host=UNKNOWN


And there is no error reported by imap_last_error().

Nothing at all is returned.

stuka
04-14-2004, 05:59 PM
Looks to me like the username isn't getting sent through correctly.

darelf
04-15-2004, 11:43 AM
host=UNKNOWN? is that a networking issue? I know that I was having problems because there were no "hosts" entry and/or no reverse DNS when I was setting up our mail server......

What kind of checking is the server doing?