0

This code working fine in my country Egypt how every when i upload it to the server which is located in UK it does not work, it seems to be a country authentication problem. Is there any way to over come this restriction even if in Hotmail settings

class Hotmail {

    private $_email;
    private $_password;
    private $_host = "{imap-mail.outlook.com:993/ssl}Inbox";

    public function __construct($email, $password) {
        $this->_email = $email;
        $this->_password = $password;
    }

    public function authenticate() {
        if ($mbox = imap_open($this->_host, $this->_email, $this->_password)) {
            $imap_obj = imap_check($mbox);
            echo "<h1>CONNECTED TO IMAP HOST</h1><h2>$this->_host (" . $imap_obj->Nmsgs . ")<h2>";
        } else {
            echo imap_last_error();
            echo "<h1>FAILED TO CONNECT TO IMAP HOST!</h1>\n";
            die;
        }

        echo "<h3>IMAP LIST OF FOLDERS</h3>";
        $folders = imap_list($mbox, $this->_host, "*");
        echo "<ul>";
        foreach ($folders as $folder) {
            echo '<li><a href="mail.php?folder=' . $folder . '&func=view">' . imap_utf7_decode($folder) . '</a></li>';
        }
        echo "</ul>";
        imap_close($mbox);
    }

}

$hotmail = new Hotmail('sahar_24@outlook.com', '01277217631!');
$hotmail->authenticate();

In Egypt in returns: CONNECTED In UK in return FAILED TO CONNECT as echo imap_last_error(); return the following message: Can not authenticate to IMAP server: [AUTHORIZATIONFAILED] Account is blocked. Login to your account via a web browse

Dahab
  • 518
  • 1
  • 5
  • 23
  • I suspect you will need to check with the host in the UK. They may block or firewall different connections. Secure IMAP Port (993) may be one of those ports. Every host can be different. You could attempt a socket connection over SSL to verify that your script can reach the server and port. I would raise this question with the server host. – Twisty May 07 '15 at 16:43
  • @Twisty the thing is that some other accounts work fine, only 2 hotmail email accounts does not work. sounds very weird. – Dahab May 07 '15 at 16:46
  • Maybe Hotmail is blocking the connection. If it works on some servers and never on this one, something is being blocked. You'll need to investigate further and I would ask the server host first. – Twisty May 07 '15 at 16:47

0 Answers0