The following email code, using an IMAP and PHP tutorial with the mail function to the example, very method, there is a third party plug-ins Oh, phpmailer to send mail.
<?php
Connect an IMAP server link with an IMAP port of 143.
$mbox = Imap_open ("{Localhost:143}inbox", "user_id", "password");
Connection POP3 Server link, POP3 port is 110.
$mbox = Imap_open ("{Localhost/pop3:110}inbox", "user_id", "password");
Connect to the NNTP Server link, NNTP has a port of 119.
$NNTP = Imap_open ("{localhost/nntp:119}comp.test", "" "" ");
?>
<?php
Connecting to an IMAP server
$mbox = Imap_open ("{imap.example.org}", "username", "password", Op_halfopen)
Or Die (Connection failed:. Imap_last_error ());
$list = Imap_getmailboxes ($mbox, "{imap.example.org}", "*");
if (Is_array ($list)) {
foreach ($list as $key => $val) {
echo "($key)";
Echo Imap_utf7_decode ($val->name). ",";
echo "". $val->delimiter. "',";
Echo $val->attributes. "<br/>n";
}
else {
echo "Imap_getmailboxes failed:". Imap_last_error (). "N";
}
Turn off IMAP connections
Imap_close ($mbox);
?>
<?php
Mail ("163@163.com", "Welcome", "Hello, hi!");
?>
<?php
//define boundary line
$boundary = Uniqid ("");
//Generate headers
$header = "From: $fromnContent-type:multipart/mixed
boundary= "$boundary" Nx-mailer:phpnx-priority:3 ";
//Get MIME type of attachment file
$mimetype = Mime_content_type (' test.zip ')
//Get Name of attachment file
$attach = ' test.zip '
// Encode and segment attachment files
$fp = fopen ($attach, "R");
$content = Fread ($fp, FileSize ($attach));
$content = Chunk_split ( Base64_encode ($content));
//Generate message body
$body = "
--$boundary
Content-type:text/plain charset=iso-8859-1
Content-transfer-encoding:8bit
$message
--$boundary
Content-type: $mimeType; name= $filename
Content-disposition:attachment; Filename= $filename
Content-transfer-encoding:base64
$content
--$boundary--";
//Send mail
Mail ($to, $ Subject, $body, $header);
<?php
$mbox =imap_open ("{Localhost:143}inbox", "myID", "MYPW");
$message =imap_body ($mbox, 1);
Imap_ Close ($mbox);
Echo$message;