Reading IMAP emails with PHP_PHP tutorial

WBOY
Release: 2016-07-21 16:07:13
Original
985 people have browsed it

//This example can be used to practice functions about IMAP
//But if you really want to write WEBMAIL, then there are more things to consider... Lone Wolf

login.php3
< ?php

if (!$PHP_AUTH_USER) {
Header("WWW-authenticate: basic realm="Mail Client Check"");
Header("HTTP/1.0 401 Unauthorized");
} else {
$MYDIR=ereg_replace("/[^/]+$","",$PHP_SELF);
Header("Location: $SERVER_NAME$MYDIR/messages.php3");
$MAILSERVER="{localhost/imap}";
$link=imap_open($MAILSERVER,$PHP_AUTH_USER,$PHP_AUTH_PW);
$headers=imap_headers($link);

for($x=1; $x < count($headers); $x++) {
$idx=($x-1);
echo "$headers[$idx]
";
}

?>

Connect after verification Go to the IMAP server $MAILSERVER

and then obtain the mailing list and create a connection to read the mail

view.php3:


$ MAILSERVER="{localhost/imap}";
$link=imap_open($MAILSERVER,$PHP_AUTH_USER,$PHP_AUTH_PW);
$header=imap_header($link,$num);

echo "From: $header[fromaddress]
";
echo "To: $header[toaddress]
";
echo "Date: $header[Date]
";
echo "Subject: $header[Subject]

";
echo imap_body($link,$num);

?>

view.php3 opens the IMAP connection and obtains the email header information and displays

This is only a small program that can be completed, you have to write it yourself!



http://www.bkjia.com/PHPjc/315192.html

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/315192.html

TechArticle//This example can be used to practice the functions of IMAP//But if you really want to write WEBMAIL, then you need to consider it There's more to it... Lone Wolf login.php3 ?php if (!$PHP_AUTH_USER) { Heade...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template