Atomic Haven
03-30-2005, 09:05 PM
Im looking for a way that I can setup PHP to check a POP3 mailbox for Outlook 2003 created Tasks/Appointments. Does anybody know of a way to do this?
I would like to be able to send a task to the mailbox itstaff@mydomain.com and have it listed on the site. Is this possible?
Azavia
03-31-2005, 07:20 PM
Have you checked the PHP IMAP functions (http://www.php.net/imap)?
Brandon
Atomic Haven
03-31-2005, 07:25 PM
Yes I have, I have most of the script working now, I just can't get it to parse the incoming file from Outlook. Here is what I have so far.
<?php
function display($mail)
{
$mail = htmlentities(stripslashes($mail));
$mailarray = explode("\n",$mail);
//$newmail = var_dump($mailarray);
$type = strpos($mailarray[0],"MIME");
$message = explode("--MESSAGE--",$mail);
if ($type == 32) {
$mail = '<BR><B>'. $mailarray[7].'</B> <BR>'.$mailarray[11] . ' - ' . $mailarray[12].'<p>'.$mailarray[17].'<br>'.$mailarray[19].'<BR><BR>'.$message[0];
return $mail;
} else {
$mail = "No Support for this message type." . $type;
return $mail;
}
}
function show_mails($server, $account, $password)
{
$mailbox = imap_open("{".$server.":110/pop3}INBOX", $account, $password);
$mails = imap_fetch_overview($mailbox,"1:*", FT_UID);
$return = '<table width="100%">
<tr>
<td><b>#</b></td>
<td><b>Assigned By</b></td>
<td><b>Date / Time</b></td>
<td><b>Subject</b></td>
</tr>';
$size = count($mails);
$cmsg = 0;
for($i=$size-1;$i>=0;$i--)
{
$cmsg++;
$value = $mails[$i];
$return .= '<tr><td>'.$cmsg.'</td><td>'.$value->from.'</td><td>'.$value->date.'</td><td><a href="'.$_SERVER['PHP_SELF'].'?id='.$value->msgno.'">'.$value->subject.'</a></td></tr>';
}
$return .= '</table>';
imap_close($mailbox);
return $return;
}
function show_mail($id, $server, $account, $password)
{
$mailbox = imap_open("{".$server.":110/pop3}INBOX", $account, $password);
$mail = imap_body($mailbox,$id, FT_UID);
$mail = htmlentities(stripslashes($mail));
$mailarray = explode("\n",$mail);
//$newmail = var_dump($mailarray);
$return = display($mail) ;
imap_close($mailbox);
return $return;
}
if(isset($_GET['id']))
if(is_numeric($_GET['id']))
echo show_mail($_GET['id'], "mail.yourdomain.com", "email@yourdomain.com", "password");
else
echo 'wrong parameter';
else
echo show_mails("mail.yourdomain.com", "email@yourdomain.com", "password");
?>