Search code examples
phpimapphp-imap

Php-cli imap_open always asking for a password


I'm trying to connect to a mailbox using imap_open, with the following simple code:

$con = imap_open(sprintf($host, '/novalidate-cert'), $userName, $password);

If I execute that via php-cli, it asks me for a password... and whatever the password I introduce, it will works. I'm sure username and password are right (tested via telnet), so I have no idea why is asking for it again.

Any idea?


Solution

  • I've been stuck with the same issue, fixed using:

    $con = imap_open(sprintf($host, '/authuser=YOURUSER'), $userName, $password);
    

    must point out that I am using an extended PHPMailer from DavidRockin

    Debugging with my mail sysadmin I've found that you need to provide /authuser flag in order to access IMAP server correctly.

    BTW Password is still prompted but no errors are issued on the server side so sysadmin won't kill you :-)

    UPDATE: use /norsh to disable preauth with rsh/ssh, password won't be prompted anymore.