Imap_open

software development

#1

I installed the custom php5 script in order to use the imap functions. However, I’m getting “Couldn’t open stream” errors when executing imap_open in my php script.

Anyone have some working code examples for imap_open as implemented at Dreamhost?

Thanks,
Kevin


#2

After a bit of research, I answered my own question…
Here’s some working sample code for any others in the same boat…

$mbox = imap_open ("{mail.mymailserver.net:143/notls}INBOX", “mylogin”, “mypassword”);

for ($i = 1; $i <= imap_num_msg($mbox); $i++)
{
$header = imap_headerinfo($mbox, $i, 80, 80);
$fromaddress[$i] = $header->from[0]->host;
$fromname[$i] = $header->from[0]->mailbox;
$from[$i]= $fromname[$i]."@".$fromaddress[$i];

$subject[$i] = $header->fetchsubject;
echo $i . " " . $from[$i]." “.$subject[$i].” \n ";

$msg = imap_body($mbox, $i);

$m = explode("\n", $msg);

foreach ($m as $ma) {
echo $ma . “
”;
}

imap_delete($mbox, $i);
}

imap_expunge($mbox);

imap_close($mbox);