Jump to content

Recommended Posts

Posted

Hi folks,

 

I'm trying to receive some mails with the IMAP module in PHP. And it won't work yet.

 

I keep getting the following error:

 

Message: Unknown: Connection failed to 213.51.146.46,21: No route to host (errflg=2)

 

I changed the serveradress (mail.home.nl) in the IP but that only worked for 1 error. This error is not gonna give up ^^.

 

I work with CodeIgniter and I'm using the following class: http://www.phphulp.nl/php/script/overig/cl...p3-reader/1356/ (dutch btw)

But I don't think it has anything to do with the code.

 

Testing Environment:

http://peterwessels.heliohost.org/Unified/...p/imap/connect/

 

The code:

 

Controller

 

<?
   function connect()
       {
       
           $data['username'] = "adres";
           $data['password'] = "wachtwoord";
           $data['server'] = "213.51.146.46";
           $data['port'] = "21";
           $data['mailboxName'] = "inbox";
           
           
           $this->load->model('Imap_model');
           $this->Imap_model->Imapmail($data);
                       
           $connect = $this->Imap_model->connect();
           if($connect == FALSE)
           {
               $this->load->view("failure");
           }
       
       }
?>

 

 

Model:

<?

public function Imapmail($data)
   {
       extract($data);
       
       
       $this->username = $username;
       $this->password = $password;
       $this->server = $server;
       $this->port = $port;
       $this->options = $options;
       $this->mailboxName = $mailboxName;
       return(true);
   }
   public function connect()
   {
       $options = "";
       if(!empty($this->options) && is_array($this->options))
       {
           while(list($key, $option) = each($this->options))
           {
               $options .= "/" . $option;
           }
       }
       
       $adress = '{' . $this->server . ':' . $this->port . $options . '}' . $this->mailboxName;
       $mbox = @imap_open($adress, $this->username, $this->password);
       $this->connection = $mbox;
       if($mbox)
       {
           return true;
       } else
       {
           return false;
       }
   }
?>

 

I hope you can check the firewall, if you can enable me to receive e-mails through imap.

 

With kind regards,

Peter Wessels

Posted

Isn't IMAP usualy port 143? I thought port 21 was usually FTP, but I guess you can use whatever port for whatever you want as long as it's open and both the server and the client both know what protocol they are using to communicate.

Posted

Yeah, but he's trying to connect on port 21.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...