-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathimap_open.php
executable file
·71 lines (64 loc) · 1.73 KB
/
imap_open.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>POP3 Example</title>
<style>
TD {
font: 10pt helvetica, sans-serif;
border: thin solid black;
}
TH {
font: bold 10pt helvetica, sans-serif;
border: thin solid black;
}
</style>
</head>
<body>
<form name="ImapExample" method=POST>
<?php
$host = "pop.1and1.com";
$user = "[email protected]";
$pwd = "Password!2";
$fmt = "{" . $host . "/pop3:110}";
$mbox = imap_open($fmt, $user, $pwd);
echo "<h1>Mailboxes</h1>\n";
$folders = imap_list($mbox, $fmt, "*");
if ($folders == false) {
echo "Call failed<br />\n";
} else {
foreach ($folders as $val) {
echo $val . "<br />\n";
}
}
echo "<h1>Headers in INBOX</h1>\n";
$headers = imap_headers($mbox);
echo "<table>\n";
if ($headers == false) {
echo "Call failed<br />\n";
} else {
foreach ($headers as $val) {
// Parse out the number
$start = strpos($val," ");
$stop = strpos($val,")");
$num = (int) substr($val, $start, $stop - $start);
$text = substr($val,$stop+1);
echo "<tr>";
echo "<td><input type=checkbox name='header[" . $num . "]'>";
echo "<td>" . htmlentities($text);
echo "<input type=hidden name='ref[" . $num . "]' value='" . $num . "'/>";
// Check to see if body was checkmarked
if (isset($_POST['header'][$num])) {
echo "<hr><p>" . htmlentities(imap_body($mbox,$_POST['ref'][$num])) . "</p>";
}
echo "</td></tr>\n";
}
}
echo "</table>\n";
imap_close($mbox);
?>
<br><input type=submit name="read" value="Read Checkmarked" />
</form>
<br><a href="index.php">BACK</a>
</body>
</html>