Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online

imap open function syntax tag tutorial 2013 Donate at flattr Flattr this





Alert! Connect with 10,000 Chating Online. Join Now

Php imap open () function

Write your php code

 
<?php ?>

Php Result


Your code below



(PHP 3, PHP 4 , PHP 5)

imap_open -- Open an IMAP stream to a mailbox

Syntax

resource imap_open ( string mailbox, string username, string password [, int options] )

Returns an IMAP stream on success and FALSE on error. This function can also be used to open streams to POP3 and NNTP servers, but some functions and features are only available on IMAP servers.

A mailbox name consists of a server part and a mailbox path on this server. The special name INBOX stands for the current users personal mailbox. The server part, which is enclosed in '{' and '}', consists of the servers name or ip address, an optional port (prefixed by ':'), and an optional protocol specification (prefixed by '/'). The server part is mandatory in all mailbox parameters. Mailbox names that contain international characters besides those in the printable ASCII space have to be encoded with imap_utf7_encode().

All names which start with { are remote names, and are in the form "{" remote_system_name [":" port] [flags] "}" [mailbox_name] where:

  • remote_system_name - Internet domain name or bracketed IP address of server.

  • port - optional TCP port number, default is the default port for that service

  • flags - optional flags, see following table.

  • mailbox_name - remote mailbox name, default is INBOX

Table 1. Optional flags for names

FlagSyntax
/service=servicemailbox access service, default is "imap"
/user=userremote user name for login on the server
/authuser=userremote authentication user; if specified this is the user name whose password is used (e.g. administrator)
/anonymousremote access as anonymous user
/debugrecord protocol telemetry in application's debug log
/securedo not transmit a plaintext password over the network
/imap, /imap2, /imap2bis, /imap4, /imap4rev1equivalent to /service=imap
/pop3equivalent to /service=pop3
/nntpequivalent to /service=nntp
/norshdo not use rsh or ssh to establish a preauthenticated IMAP session
/ssluse the Secure Socket Layer to encrypt the session
/validate-certvalidate certificates from TLS/SSL server (this is the default behavior)
/novalidate-certdo not validate certificates from TLS/SSL server, needed if server uses self-signed certificates
/tlsforce use of start-TLS to encrypt the session, and reject connection to servers that do not support it
/notlsdo not do start-TLS to encrypt the session, even with servers that support it
/readonlyrequest read-only mailbox open (IMAP only; ignored on NNTP, and an error with SMTP and POP3)

The options are a bit mask with one or more of the following:

  • OP_READONLY - Open mailbox read-only

  • OP_ANONYMOUS - Don't use or update a .newsrc for news (NNTP only)

  • OP_HALFOPEN - For IMAP and NNTP names, open a connection but don't open a mailbox.

  • CL_EXPUNGE - Expunge mailbox automatically upon mailbox close (see also imap_delete() and imap_expunge())

  • OP_DEBUG - Debug protocol negotiations

  • OP_SHORTCACHE - Short (elt-only) caching

  • OP_SILENT - Don't pass up events (internal use)

  • OP_PROTOTYPE - Return driver prototype

  • OP_EXPUNGE - Silently expunge recycle stream

  • OP_SECURE - Don't do non-secure authentication

Example 1. Different use of imap_open()

<?php
// To connect to an IMAP server running on port 143 on the local machine,
// do the following:
$mbox = imap_open("{localhost:143}INBOX", "user_id", "password");

// To connect to a POP3 server on port 110 on the local server, use:
$mbox = imap_open ("{localhost:110/pop3}INBOX", "user_id", "password");

// To connect to an SSL IMAP or POP3 server, add /ssl after the protocol
// specification:
$mbox = imap_open ("{localhost:993/imap/ssl}INBOX", "user_id", "password");

// To connect to an SSL IMAP or POP3 server with a self-signed certificate,
// add /ssl/novalidate-cert after the protocol specification:
$mbox = imap_open ("{localhost:995/pop3/ssl/novalidate-cert}", "user_id", "password");

// To connect to an NNTP server on port 119 on the local server, use:
$nntp = imap_open ("{localhost:119/nntp}comp.test", "", "");
// To connect to a remote server replace "localhost" with the name or the
// IP address of the server you want to connect to.
?>

Example 2. imap_open() example

<?php
$mbox
= imap_open("{your.imap.host:143}", "username", "password");

echo
"<h1>Mailboxes</h1>\n";
$folders = imap_listmailbox($mbox, "{your.imap.host:143}", "*");

if (
$folders == false) {
    echo
"Call failed<br />\n";
} else {
    while (list (
$key, $val) = each($folders)) {
        echo
$val . "<br />\n";
    }
}

echo
"<h1>Headers in INBOX</h1>\n";
$headers = imap_headers($mbox);

if (
$headers == false) {
    echo
"Call failed<br />\n";
} else {
    while (list (
$key, $val) = each ($headers)) {
        echo
$val . "<br />\n";
    }
}

imap_close($mbox);
?>

Php imap open Function syntax tag

imap open php code on this is provided for your study purpose, it will guide you to know how create and design a website using php. use it to practice and train your self online



Php imap open syntax tutorial

php tutorial guide and code design are for easy learning and programming. The code practice section provided at the top is for practising of this syntax. Use the code section up to practice your php programming online. Learning php is very easy, all you need is to use the examples on this site and practice them to perfect your skills.


Function index

Variables

Expressions

Operators

Control-Structures

Cookies

Array

Date & Time

Directory function

File

Image

Operators

Form data handling

Mathematics operators

Mail

Php Mysql

Network Functions

Strings

php tutorial guides,functions, classes, code examples and tags for creating simple dynamic site to mysql database driven sites
 
 
Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online