Peeker Connect


Peeker Connect Class

This class connects to IMAP or POP servers and tells you if there are messages waiting.

Features:

Note:  This class can be used alone as a lightweight way to check if an email account has messages waiting, but for most email retrieval tasks, it is designed to work with the main peeker class; it is an ancestor class. This class only connects to the IMAP or POP server and detects if there are any messages waiting. You need to use the main Peeker class to actually count and get the messages.

Connecting to IMAP or POP server

Enter your mailserver connection data and run a few lines of code.

There are many different types of mail servers. Each one has its own requirements.

Example POP connection

Connect to a password-protected POP server using the Peeker Connect class:

$config['login']='your_username';
$config['pass']='your_password';
$config['host']='mail.example.com';
$config['port']='110';
$config['service_flags'] = '/pop3/notls';

// you can pass config as second parameter or use initialize()
// $this->load->library('peeker_connect', $config);

$this->load->library('peeker_connect');
$this->peeker_connect->initialize($config);
if ($this->peeker_connect->message_waiting())
{
echo "You've got mail!";
}

$this->peeker_connect->close();

// now tell us the story of the connection
print_r($this->peeker_connect->trace());

Config items

IMAP and POP server data. Star* indicates config item is required to be set to something other than default.

Config Default Value Options Description
login NULL* any valid login string IMAP or POP server login name.
pass NULL* any valid password string IMAP or POP server password.
host NULL* the fully-qualified domain name for a mailserver e.g., mail.example.com
port NULL* the port number, typically 110, 143, 443, 993, etc... e.g., 110 (for POP3)
service_flags NULL* any valid service flag string (see http://php.net/imap-open) Change these to fit your server settings. For instance, some servers require SSL and Certificates and some don't.
mailbox NULL any valid mailbox name (used only for IMAP, not POP) POP servers don't use a mailbox name, use 'INBOX' for IMAP or another mailbox name in the IMAP account

The config array can be sent on library load, by passing to the initialize() method (as shown on this page), or by using the Code Igniter config file convention (see the CI manual for details).

Function Reference

$this->peeker_connect->initialize($config_array)

After loading the library, call initialize() to establish a connection.

$this->peeker_connect->initialize($config_array);

$this->peeker_connect->is_connected()

After initialize is called, you can check the connection. Returns TRUE or FALSE.

$this->peeker_connect->is_connected();

$this->peeker_connect->message_waiting()

Check if there is at least one message waiting. Returns TRUE or FALSE.

NOTE: Only returns the messages waiting on the initial connection with the server.

This is useful for a "You've got mail!" indicator.

$this->peeker_connect->message_waiting();

Note: The connect class does not count messages or get messages (you need the main peeker class for that).

$this->peeker_connect->close()

Close the IMAP or POP connection.

$this->peeker_connect->close();