Go Back   HostGator Peer Support Forums > HostGator Peer Support Forums > Web Hosting Services

Notices

Reply
 
Thread Tools
  #1  
Old 09-11-2006, 05:15 AM
davidb2002 davidb2002 is offline
Hatchling Croc
 
Join Date: Oct 2005
Posts: 15
Question PHP Imap functions not working?

I have checked with online support and phpinfo() to make sure that php support imap, and it does. So why is it that when I execute the code below nothing at all returns, not even the echo commands?

Code:
<?php

echo 'before imap_open';

//connect to mail server
$inbox = imap_open("{localhost:143}","account@host.com","password") or die('Could not connect to mail server');

echo 'after imap_open';

$num_msg = $imap_num_msg($inbox);
echo $num_msg;

imap_close($inbox);
?>
Reply With Quote
  #2  
Old 12-05-2006, 07:49 AM
dave111 dave111 is offline
Hatchling Croc
 
Join Date: May 2005
Posts: 32
Default Re: PHP Imap functions not working?

I am also having problems with the IMAP functions (only related to message header functions thought)

Did you get any solution to this?
Reply With Quote
  #3  
Old 12-16-2006, 09:41 AM
Serra's Avatar
Serra Serra is offline
Veteran Croc
 
Join Date: Feb 2005
Location: Orange Park, FL
Posts: 5,073
Default Re: PHP Imap functions not working?

This code works:

PHP Code:
<?php

function imap_purge($IP,$user,$pass,$mode){


    
$mbox = @imap_open("{".$IP.":143}"$user$pass);

if(
$mbox){
    
$folders imap_listmailbox($mbox"{".$IP.":143}""*");
    echo 
"<h1>Headers in INBOX for $user</h1>\n";
    for (
$i 1$i <= imap_num_msg($mbox); $i++){

        
$header imap_headerinfo($mbox$i8080);
        
$subject$header->fetchsubject;
        
$date $header->udate;

        
$udate=time();

        
//number of days to purge after
        
$purge_after 5;

        
$messageBody imap_body($mbox$i);

        
$age = ($udate $date)/86400;
        echo  
$i.") ".$subject." - Age: ".number_format($age,0)."<br>";

        if(
$age $purge_after and $mode == "A"){
            
imap_delete($mbox$i);
            echo 
"Delete old message $i<br>";
        

        }

        
        
//delete all spam, even if new.
        
if(strstr($subject,"{Spam?}")){
            if(
$mode == "A")
            
imap_delete($mbox$i);
            echo 
"Delete spam: $i<br>";
        }

        
//if clear mode, delete all mail
        
if($mode == "C")
           
imap_delete($mbox$i);

    }

    
//except in test mode, expunge the delete files.


    
if($mode != "T")
       
imap_expunge($mbox);

    
imap_close($mbox);
  } else {
  
   echo 
"IMAP Access denied<br>";
   
   }

}

//MODES:  T = Test mode, A = Run mode, C = Clear all messages in box.  Run mode delete messages, test mode lists messages.

imap_purge("76.54.8.220","admin1@fbi.gov","s2oqlg2f28","A");



?>

This code is a little different, its for purging messages from an account, but it should show you how to access your account. If this code doesn't work, contact support.
__________________
Six stages of Dedi Ownership

Fashionable broken link
image included
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 10:07 PM.