<?
$inbox = imap_open ("{mail.server.dk:143/notls}", "navn@domæne.dk", "password");
$sidste = imap_num_msg($inbox);
$i = 1;
while (!$billede && $i < 10) {
$indhold = imap_fetchbody($inbox, $sidste, $i);
$fil = fopen("./temp.fil", "w");
fwrite($fil, base64_decode($indhold));
fclose($fil);
$i++;
$mimetype = mime_content_type("./temp.fil");
if (eregi("image/", $mimetype)) {
$filtype = explode("/", $mimetype);
$filtype = $filtype[1];
if ($filtype == "jpeg")
$filtype = "jpg";
if ($filtype == "x-png")
$filtype = "png";
$filnavn = md5($indhold);
@unlink($filnavn.".".$filtype);
rename("temp.fil", $filnavn.".".$filtype);
break;
}
}
$i = 1;
while (!$billede && $i < 10) {
$indhold = imap_fetchbody($inbox, $sidste, $i);
$fil = fopen("./temp2.fil", "w");
// fwrite($fil, base64_decode($indhold));
fwrite($fil, $indhold);
fclose($fil);
$i++;
$mimetype = mime_content_type("./temp2.fil");
if (eregi("text/", $mimetype)) {
$filtype2 = explode("/", $mimetype);
$filtype2 = $filtype2[1];
if ($filtype2 == "plain")
$filtype2 = "txt";
if ($filtype2 == "html")
$filtype2 = "html";
$filnavn2 = md5($indhold);
@unlink($filnavn2.".".$filtype2);
rename("temp2.fil", $filnavn2.".".$filtype2);
break;
}
}
$mailinfo = imap_fetch_overview($inbox, $sidste);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "
http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="
http://www.w3.org/1999/xhtml" xml:lang="da">
<head>
<title>E-mail</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="imagetoolbar" content="false" />
<style type="text/css">
body {
font-size: 12px;
font-family: sans-serif;
background: #ffffff;
color: #000000;
}
pre {
font-size: 12px;
font-family: sans-serif;
background: #dddddd;
color: #000000;
border: solid 1px #000000;
padding: 2px;
}
</style>
</head>
<body>
<div>Seneste e-mail til navn@domæne.dk:<br> </div>
<div><strong>Emne:</strong></div>
<?="<pre>".$mailinfo[0]->subject."</pre>";?>
<div><strong>Indhold:</strong></div>
<?="<pre>".$indhold."</pre>";?>
<?
if ($filnavn)
echo "
<div><strong>Vedhæftet billede:</strong></div>
<div> <br><img src=\"$filnavn.$filtype\"></div>";
?>
</body>
</html>
----------------------------
det den gør er at vise subject, body og det (første) vedhæftede billede.
jeg håber du kan bruge det til noget, og du er selvfølgelig velkommen til at arbejde videre på det.
hvis du en dag har et færdigt resultat vil jeg gerne lige se det.
=)