PHP imap_open
I don’t know about you, but Exchange 2007 has some funny issues. Todays one for me was trying to connect from PHP and finding that it’s not standard. To get around this I set the Exchange Imap to accept plain text as a login (it’s internal only on 143, ssl for external so no bother) and then used the following code to read the headers:
<head></head>
<body>
<?php
$imap = imap_open(“{SERVER:143/imap/novalidate-cert/debug}INBOX”, “[email protected]”, “UserPass”) or die(“can’t connect: “.imap_last_error());echo “<h2>Current IT Job List </h2>\n”;
$headers = imap_headers($imap);if ($headers == false) {
echo “Call failed<br />\n”;
} else {
foreach ($headers as $val) {
echo “Job #” . $val . “<br />\n”;
}
}imap_close($imap);
?>
<br><br>
<p>If your item isn’t on this list, then you haven’t submitted a ticket.</p>
</body>
</html>
Now I was getting an error to start off with. This happens if you have an unpatched version of php-imap. The work around is to shell on to your php server and do:
apt-get install hiemdal-clients su www-data kinit [email protected] 'Mind the case [email protected]
Only issue is, this is a 24hr check out and you’ll need to do it every day. Other option is to do this with a cron job and put the password for the user in a file, use the latest PHP version or compile php from source without kerberos support. The choice, is yours.