IMAP connection

software development

#1

Hi, i am trying to write a php script that uses an imap connection but am having troubles.

I have compiled my own copy of php and that seems to be working fine. Whenever i run the following script, i recieve a warning message.

$host = “{mail.domain.co.uk:143/imap}”;
$user = “m2304889”;
$pass = “PASS”;
$mbox = imap_open($host, $user, $pass);

Error Message:

Warning: imap_open() [function.imap-open]: Couldn’t open stream {mail.domain.co.uk:143/imap}

Am i using the correct connection string? thanks for any help.

Lewis.


#2

Try

{mail.domain.co.uk:143/imap}INBOX

Make sure there is no white space


#3
<?php session_start();?> PHP & IMAP, A DREAMHOST EXAMPLE <?php if(isset($_REQUEST[logout])){ session_destroy(); header("location: ."); } if(isset($_POST[submit])){ $strEmail = $_POST[email]; $strPassword = $_POST[password]; @list($strAccount, $strHost) = split('@', $strEmail); if(!$strHost == ''){ $strHost = 'mail.'.$strHost; $imap = @imap_open("{".$strHost."/imap/ssl/novalidate-cert}INBOX",$strEmail,$strPassword); if(!$imap){ echo 'Can\'t connect to '.$strAccount.'\'s '.$strHost.' account.'; }else{ $_SESSION[strEmail] = $strEmail; $_SESSION[strPassword] = $strPassword; $_SESSION[strHost] = $strHost; $_SESSION[bolOpen] = true; @imap_close(); } }else{ echo '"'.$strEmail.'" is not a valid email address!'; } } if($_SESSION[bolOpen]){ $strEmail = $_SESSION[strEmail]; $strPassword = $_SESSION[strPassword]; $strHost = $_SESSION[strHost]; $imap = @imap_open("{".$strHost."/imap/ssl/novalidate-cert}INBOX",$strEmail,$strPassword); echo 'Logout'; $imap_headers = @imap_headers($imap); $intEmails = @sizeof($imap_headers); if($intEmails>=1){ echo '

'.$strEmail.'\'s email...

    '; } for($i=1;$i<$intEmails+1;$i++){ $imap_header = @imap_headerinfo($imap,$i); $strFrom = $imap_header->from; if(is_array($strFrom)){ $strFrom = $strFrom[0]->mailbox.$strFrom[0]->host; } echo '
  1. '.$strFrom.'
  2. '; } if($intEmails>=1){ echo '
'; }else{ echo 'Try sending an email to '.$strEmail.'...'; } @imap_close($imap); }else{ echo ' address@domain.tld
password
'; } ?>