Is there any alternative to checking a POP3 email account that the standard IMAP commands... My server isn't allowing me to use those.

    I'd really love to know the answer to this too. Hopefully there's a method that does not use IMAP (imap_open is crashing on my host server and we can't find the problem) and has the ability to grab attachments.

    TIA,
    chicken

      I've written several classes which connect to the POP3 server using sockets...maybe something like that would work for you?

        yeah probably. If I can connect via a socket and grab the emails I can use the Pear MIMEmail class to decode them in to what I need (most likely).

        links?

        -chicken

          Don't have any links unfortunatly...what code do you want and I'll get it to you...

            whoa... we're both orange.

            If you have classes / code that takes care of connecting to a POP3 server via sockets and can grab the emails in their entirety that's what I need.

            This is really all I need:
            a) connect to server
            b) grab every email
            c) after I've processed the email, delete it from server

            Thanks a ton,
            chicken

              There are several POP3 classes in the code library on this site. Perhaps one of them may help you.

              CHris

                Well, let me give you the following then:

                class POP3Mail
                	{
                	function Connect ( $HOST , $PORT , $TIMEOUT , $USERNAME , $PASSWORD )
                		{
                		$port = ( $PORT ) ? $PORT : "110";
                		$timeout = ( $TIMEOUT ) ? $TIMEOUT : "60";
                		$this->MyConnection = fsockopen( $HOST , $port , &$en , &$ed , $timeout );
                		if ( ! $this->MyConnection )
                			{
                			return "111"; /* Unable to Connect to Host */
                			}
                		$this->Listen();
                		$response = $this->Ask( "USER $USERNAME" );
                		if ( $this->isError( $response ) )
                			{
                			return "121"; /* Invalid Username */
                			}
                		$response = $this->Ask( "PASS $PASSWORD" );
                		if ( $this->isError( $response ) )
                			{
                			return "122"; /* Invalid Password */
                			}
                		$stats = explode ( " " , $this->Ask( "STAT" ) );
                		$this->MailboxMessages = $stats[1];
                		$this->MailboxSize = $stats[2];
                		return "OK";
                		}
                	function GetMessage ( $message )
                		{
                		$body = $this->Ask( "RETR $message" , 1 );
                		if ( $this->isError( $body[0] ) )
                			{
                			return "301"; /* Invalid RETR command */
                			}
                		array_shift( $body );
                		return $body;
                		}
                	function DeleteMessage ( $message )
                		{
                		$this->Say( "DELE $message" );
                		}
                	function MessageCount ()
                		{
                		return $this->MailboxMessages;
                		}
                	function Disconnect ()
                		{
                		$this->Say( "QUIT" );
                		fclose( $this->MyConnection );
                		}
                
                function Ask ( $command , $longanswer = 0 )
                	{
                	$this->Say( $command );
                	$response = $this->Listen();
                	if ( $longanswer )
                		{
                		while ( ! ( trim( $response ) == "." ) )
                			{
                			if ( ! ( trim( $response ) == "." ) )
                				{
                				$answer[] .= $response;
                				$response = $this->Listen();
                				}
                			}
                		$response = $answer;
                		}
                	return $response;
                	}
                function Say ( $command )
                	{
                	fputs ( $this->MyConnection , $command."\r\n" );
                	}
                function Listen ()
                	{
                	return fgets ( $this->MyConnection , $this->MyBuffer );
                	}
                function isError ( $response )
                	{
                	return ( substr( $line, 0, 3 ) == "-ER" ) ? TRUE : FALSE;
                	}
                }
                

                Hope it's understandable...I had to strip it from a larger project. Here's how it should work:

                $email = new POP3Mail;
                $email->Connect($host,$port,$timtout,$username,$password);
                for ($x = 0;$x<=$email->MessageCount;$x++)
                	{
                	$MyMessages[$x] = $email->GetMessage( $x );
                	$email->DeleteMessage( $x );
                	}
                $email->Disconnect();
                

                Hope this works for you! Let me know if it doesn't!

                Lewis

                  OK, tried it. Doesn't work for me. Connect() creates a resource ID correctly (I believe) but Listen() doesn't get a response.

                  Any way for me to doublecheck that it's successfully connecting?

                  -chicken

                    Ah...I see the problem. In the listen function, change $this->MyBuffer to 1024. That should make it work...

                    Sorry about that!

                    Lewis

                      Write a Reply...