Mail piping problem with PHP script - Help please

Mar

Member
Mar 23, 2003
10
0
151
Warning: imap_open(): Couldn't open stream {mail.XXXX.com/pop3:110}INBOX in /home/xxxx/public_html/helpdesk/receive.php on line 161

I'm a newbie to this and my helpdesk script's causing this problem on my cPanel hosting account; the code reads -

$query = "SELECT * FROM mail_accounts";
$mail_accounts = mysql_query($query);
while ($mails = mysql_fetch_array($mail_accounts))
{
$receive_server = $mail_servers[$mails["ms_id"]];
$r_login = $mails["login"];
$r_password = $mails["passwd"];
if ($mail_servers_type[$mails["ms_id"]] == "p") $receive_server .= "/pop3:110";
else $receive_server .= ":143";

if ($mbox = imap_open("\{$receive_server}INBOX", $r_login, $r_password))

I really need to get this sorted for cPanel hosting , so if anyone is able to help, I'd really appreciate it.

Thanks
Mar
 

Mar

Member
Mar 23, 2003
10
0
151
is there anything specific I should be asking my host about compiling IMAP on the server to make this script work? .... what I know about an IMAP program could be written on a postage stamp - and currently probably should!

The script used to work ok - and then one night it just stopped receiving tickets. Since then, I can only make it work on hosting of the DirectAdmin/Ensim flavor .

Thanks
M
 

chirpy

Well-Known Member
Verifed Vendor
Jun 15, 2002
13,437
31
473
Go on, have a guess
Firstly, I'm not a PHP programmer (I only do perl) but:

1. This is not a piping problem, because the script is logging into the POP3 account and retrieving email, it is not being sent from the MTA directly to the script (which is piping)

2. I may be wrong, but I believe that the method being used in the script probably uses PHP sockets() which are not built by default into PHP. So my guess would be that you need PHP recompiled with sockets() support enabled.

I could easily be completely wrong, though.
 

Mar

Member
Mar 23, 2003
10
0
151
OK, thanks - I'm away to try that and see if it helps :)

will let you know.

M
 

Host4u2

Well-Known Member
Mar 24, 2002
247
0
316
According to your php.info, sockets are already enabled:

Configure Command:

'./configure' '--with-apxs=/usr/local/apache/bin/apxs' '--with-xml' '--enable-bcmath' '--enable-calendar' '--with-curl' '--enable-ftp' '--with-gd' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr' '--with-xpm-dir=/usr/X11R6' '--with-imap' '--with-imap-ssl' '--with-kerberos' '--with-mcrypt' '--enable-magic-quotes' '--with-mysql' '--with-pear' '--enable-sockets' '--enable-track-vars' '--enable-versioning' '--with-xmlrpc' '--with-zlib'
 

Mar

Member
Mar 23, 2003
10
0
151
It would've been nice ...

sockets support is ok, so that's another line of thought crossed off the list of possibilities. -

I'm open to suggestions if anyone can see the problem!

Thanks for all comments in the meantime.

Mar
 

chirpy

Well-Known Member
Verifed Vendor
Jun 15, 2002
13,437
31
473
Go on, have a guess
Ah well, i tried :(

How about this, then: if your POP3 access is on the same server as your web access, you can try changing mail.XXXX.com (where ever you enter that) to the single word:

localhost

If that doesn't work, you might need to monitor the /var/log/maillog file while running the script to see if a POP3 error is generated at the same time.

You should also check that the server is not blocking (via a firewall) *outbound* connections on port 110.
 

Mar

Member
Mar 23, 2003
10
0
151
Thanks - I'll try that and see if we get anywhere further.

Mar
 

Mar

Member
Mar 23, 2003
10
0
151
Localhost

was a great answer! Many thanks for all your help.

Mar
 

CoolMike

Well-Known Member
Sep 6, 2001
313
0
316
Does it work now? Because we have exactly the same problem, what was the solution?

Thanks
Mike
 

chirpy

Well-Known Member
Verifed Vendor
Jun 15, 2002
13,437
31
473
Go on, have a guess
The answer is to change the domain to the single word localhost

When this fixes a problem, it's usually down to a local DNS misconfiguration.
 

CoolMike

Well-Known Member
Sep 6, 2001
313
0
316
Hmm, in this case I have another problem:

Code:
$mbox = imap_open ("{localhost:143}INBOX", "[email protected]", "password");
The output is just blanks and hangs, and in lynx I can read something about Network error.

Any other ideas?

Thanks
Mike
 

Host4u2

Well-Known Member
Mar 24, 2002
247
0
316
Ths issue was originally posted regarding sending mail via a helpdesk php script, and using localhost worked in the script where calling "/pop3:110" did not. There was/is no dns misconfiguration :)