POP3 mit PHP abrufen und bei bestimmten Absender email an andere adresse senden

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • #16
    Ja, wir Gladbacher werden immer meht

    Kommentar


    • #17
      Wir sind ja auch die coolsten!

      nun zu der pop klasse,
      ich bekomme immer folgende Meldung:

      no server given!

      ich habe als server "localhost" und "meinedomain.de" versucht, andere daten habe ich nicht, da ich auch unter outlook z.B. meinedomain.de als pop und smtp eintragen muß. Woher kommt der Fehler???

      Kommentar


      • #18
        wie benutzt du die Klasse?

        zeig doch mal bitte Code!
        du hast bestimmt innerhalb der Klasse rumgefummelt
        und nicht die Parameter benutzt
        TBT

        Die zwei wichtigsten Regeln für eine berufliche Karriere:
        1. Verrate niemals alles was du weißt!


        PHP 2 AllPatrizier II Browsergame

        Kommentar


        • #19
          Ich hab nicht rumgefummelt!!!

          PHP-Code:
          <?
          include("pop3.class.php");
          $pop3 = new POP3( $server, $port, $user, $pass );
          if ( !$pop3error = $pop3->open() ) {
              if ( !$pop3error = $pop3->login() ) {
                  if ( !$pop3error = $pop3->stat() ) {
                      $mail_sizes = $pop3->listing();
                      $ids = $pop3->ids();
                      $row = "";
                      for( $ii = 1;$ii <= count( $mail_sizes );++$ii ) {
                          if ( in_array( $ids[$ii], $alreadyhave ) ) { // alreadyhave ist ein Array mit Mailids
                              continue; // welche nicht nochmal vom Server geholt werden
                          }
                          $headers = $body = $h = $b = "";
                          if ( ( $pop3error = $pop3->retrieve( $ii, $headers, $body ) ) == "" ) {
                              for( $line = 0;$line < count( $headers );$line++ ) {
                                  $h .= addslashes( $headers[$line] ) . "\r\n";
                              }
                              for( $line = 0;$line < count( $body );$line++ ) {
                                  $b .= addslashes( $body[$line] ) . "\r\n";
                              }
                              $row = "('" . $ids[$ii] . "'," . $server[$i][0] . ",'$h','$b')";
                          }
                          $sql .= ( $sql?",":"" ) . $row;
                      }
                  }
              }
          }
          if ( $pop3error ) {
              echo $pop3error;
          }
          $pop3->disconnect();
          echo $row;
          ?>
          und hier deine nicht befummelte Klasse:

          PHP-Code:
          <?
          /**
           * class:         pop3.class.php
           * require:
           * optional:
           * description:    class for retrieving mail from pop3 server
           * created:        05.09.2002
           * last change:    18.09.2002
           * author:        Sven Denkert <sven.denkert@t-online.de>
           * copyright:    Sven Denkert
           *
           * TODO:        MIME Mails and Attachment
           */

          if ( !isset( $_CLASS_POP3_ ) ) {
              $_CLASS_POP3_ = 1;
              class POP3 {
                  var $server = "localhost";
                  var $port = 110;
                  var $user = "Benutzername";
                  var $pass = "Passwort";

                  var $error = "";
                  var $con = 0;
                  var $status = "disconnected";
                  var $debug = 0;

                  var $header = array();
                  var $body = array();
                  var $size = array();
                  var $ids = array();

                  function POP3( $_server = "", $_port = 110, $_user = "", $_pass = "" )
                  {
                      $this->server = $_server;
                      $this->port = $_port;
                      $this->user = $_user;
                      $this->pass = $_pass;
                  }
                  function connect()
                  {
                      $this->debugger( "connecting to server" );
                      if ( !$this->server )
                          return $this->error = "no server given!";
                      if ( !( $this->con = fsockopen( $this->server, $this->port, $error ) ) ) {
                          switch ( $error ) {
                              case -3:
                                  return $this->error = "socket could not be created";
                              case -4:
                                  return $this->error = "dns lookup on hostname \"" . $this->server . "\" failed";
                              case -5:
                                  return $this->error = "connection refused or timed out";
                              case -6:
                                  return $this->error = "fdopen() call failed";
                              case -7:
                                  return $this->error = "setvbuf() call failed";
                              default:
                                  return $this->error = $error . " could not connect to the host \"" . $this->server . "\"";
                          }
                      }
                      $this->status = "connected";
                  }
                  function disconnect()
                  {
                      $this->debugger( "disconnecting" );
                      if ( $this->con ) {
                          fclose( $this->con );
                          $this->con = 0;
                      }
                  }
                  function open()
                  {
                      $this->debugger( "open mailslot" );
                      if ( $this->status != "connected" ) {
                          if ( $this->error = $this->connect() )
                              return $this->error;
                          if ( $this->tokenize( $this->get(), " " ) != "+OK" )
                              return $this->error = "could not open connection";
                          $this->status = "authorize";
                          return "";
                      }
                  }
                  function login()
                  {
                      if ( $this->status != "authorize" )
                          return $this->error = "no authorize state";
                      if ( !$this->put( "USER " . $this->user ) )
                          return $this->error = "Could not send the USER command";
                      if ( $this->tokenize( $this->get(), " " ) != "+OK" )
                          return $this->error = "Could not get USER response";
                      if ( !$this->put( "PASS " . $this->pass ) )
                          return $this->error = "Could not send the PASS command";
                      if ( $this->tokenize( $this->get(), " " ) != "+OK" )
                          return $this->error = "Username or Password not correct ?";
                      $this->status = "loggedin";
                  }
                  function put( $line )
                  {
                      $this->debugger( "puting line: $line" );
                      return( fputs( $this->con, "$line\r\n" ) );
                  }
                  function get()
                  {
                      for( $line = "";; ) {
                          if ( feof( $this->con ) )
                              return 0;
                          $line .= fgets( $this->con, 100 );
                          $length = strlen( $line );
                          if ( $length >= 2 && substr( $line, $length-2, 2 ) == "\r\n" ) {
                              $line = substr( $line, 0, $length-2 );
                              $this->debugger( " getting line from server: " . $line );
                              return $line;
                          }
                      }
                  }
                  function debugger( $text )
                  {
                      if ( $this->debug )
                          echo $text . "<br>";
                  }
                  function tokenize( $text, $token )
                  {
                      $this->token = $token;
                      $this->tokentext = $text;
                      if ( $pos = strpos( $text, $token ) ) {
                          $this->tokentext = substr( $text, $pos + 1 );
                          $this->debugger( "returning from tokenize: " . substr( $text, 0, $pos ) );
                          return substr( $text, 0, $pos );
                      }
                      $this->debugger( "returning from tokenize: " . $text );
                      return $text;
                  }
                  function nexttoken()
                  {
                      return $this->tokenize( $this->tokentext, $this->token );
                  }
                  function stat()
                  {
                      if ( $this->status != "loggedin" )
                          return $this->error = "not logged in";
                      if ( $this->put( "STAT" ) == 0 )
                          return $this->error = "Could not send the STAT command";
                      if ( $this->tokenize( $this->get(), " " ) != "+OK" )
                          return $this->error = "Could not get STAT response";
                      $this->debugger( "mailcount: " . $mail_count = $this->nexttoken() );
                      $this->debugger( "mailsize: " . $mail_size = $this->nexttoken() );
                  }
                  function &listing()
                  {
                      if ( $this->status != "loggedin" )
                          return $this->error = "not logged in";
                      if ( $this->put( "LIST" ) == 0 )
                          return $this->error = "Could not send the LIST command";
                      if ( $this->tokenize( $this->get(), " " ) != "+OK" )
                          return $this->error = "Could not get LIST response";
                      while ( true ) {
                          $response = $this->get();
                          if ( $response == "." )break;
                          $message = intval( $this->tokenize( $response, " " ) );
                          $this->size[$message] = $this->nexttoken();
                          $this->ids[$message] = $this->nexttoken();
                      }
                      return $this->size;
                  }
                  function &ids()
                  {
                      return $this->ids;
                  }
                  function retrieve( $message, &$header, &$body )
                  {
                      if ( $this->status != "loggedin" )
                          return $this->error = "not logged in";
                      if ( $this->put( "RETR $message" ) == 0 )
                          return $this->error = "Could not send the RETR command";
                      if ( $this->tokenize( $this->get(), " " ) != "+OK" )
                          return $this->error = "Could not get RETR response";
                      $header = $body = array();
                      for( $line = 0;;$line++ ) {
                          if ( GetType( $response = $this->get() ) != "string" )
                              return $this->error = "Could not retrieve the message";
                          switch ( $response ) {
                              case ".":
                                  return( "" );
                              case "":
                                  break 2;
                              default:
                                  if ( substr( $response, 0, 1 ) == "." )
                                      $response = substr( $response, 1, strlen( $response )-1 );
                                  break;
                          }
                          $header[$line] = $response;
                      }
                      for( $line = 0;;$line++ ) {
                          if ( GetType( $response = $this->get() ) != "string" )
                              return $this->error = "Could not retrieve the message";
                          switch ( $response ) {
                              case ".":
                                  return( "" );
                              default:
                                  if ( substr( $response, 0, 1 ) == "." )
                                      $response = substr( $response, 1, strlen( $response )-1 );
                                  break;
                          }
                          $body[$line] = $response;
                      }
                      return "";
                  }
              }
          }
          ?>

          Kommentar


          • #20
            und $server ist hier auch ordentlich gefüllt ?
            PHP-Code:
            $pop3 = new POP3$server$port$user$pass ); 
            TBT

            Die zwei wichtigsten Regeln für eine berufliche Karriere:
            1. Verrate niemals alles was du weißt!


            PHP 2 AllPatrizier II Browsergame

            Kommentar


            • #21
              PHP-Code:
              <?
              include("pop3.class.php");
              $pop3 = new POP3( $server, $port, $user, $pass );
              Demzufolge nein!

              Kommentar


              • #22
                Übernimmt der die nihct aus der class?

                Kommentar


                • #23
                  wieso sollte er? noch dazu, wenn du die daten mit "" überschreibst???

                  Kommentar


                  • #24
                    Ich gehe doch richtig davon aus das ich die Daten hier eintrage für das gesammte Script oder?

                    PHP-Code:
                    if ( !isset( $_CLASS_POP3_ ) ) {
                        
                    $_CLASS_POP3_ 1;
                        class 
                    POP3 {
                            var 
                    $server "localhost";
                            var 
                    $port 110;
                            var 
                    $user "Benutzername";
                            var 
                    $pass "Passwort"

                    Kommentar


                    • #25
                      NEIN!!!

                      guck dir mal den Konstruktor und mein vorheriges Post an.

                      Kommentar


                      • #26
                        Original geschrieben von TBT
                        es gibt in den Codeschnipseln jeweils eine Klasse von mir
                        zum abrufen eines POP3 Accounts, und zum senden über
                        SMTP - ohne Imap Funktionen
                        wo finde ich die den. habe das scriptarchive nach mail durchsucht aber nichts gefunden.

                        und in meiner php info taucht nur an dieser stelle imap auf:

                        Loaded Modules : mod_imap

                        hab ich das nun oder nicht ?
                        Ein blue screen ist nicht immer was schlimmes... es hängt nur davon ab wo er zu sehen ist !
                        www.d-creationz.de

                        Kommentar


                        • #27
                          Original geschrieben von reaVen
                          wo finde ich die den. habe das scriptarchive nach mail durchsucht aber nichts gefunden.
                          nicht das scriptarchiv, sollst du durchsuchen,

                          sondern die codeschnipsel!
                          INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


                          Kommentar


                          • #28
                            ah dann kann ich ja lange suchen.
                            so hab das ding mal auf meinen server geknallt.
                            jetzte kommt aber ne fehlermeldung:

                            Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/www/htdocs/d-creationz.de/tmp/pop3.php on line 25

                            Fatal error: Call to a member function on a non-object in /home/www/htdocs/d-creationz.de/tmp/pop3.php on line 71

                            PHP-Code:

                            //25
                                        
                            for( $ii 1;$ii <= count$mail_sizes );++$ii ) {

                                            if ( 
                            in_array$ids[$ii], $alreadyhave ) ) { // alreadyhave ist ein Array mit Mailids

                                                
                            continue; // welche nicht nochmal vom Server geholt werden

                                            


                            //71

                            if ( $sql ) {

                                
                            $query->insert"insert into mails (mailserver_id,server_id,header,body) values $sql);


                            Ein blue screen ist nicht immer was schlimmes... es hängt nur davon ab wo er zu sehen ist !
                            www.d-creationz.de

                            Kommentar


                            • #29
                              also ein Herr D-Creations sollte wohl in der Lage sein mit der Fehlerbeschreibung
                              Wrong datatype for second argument
                              klarzukommen. Ansonsten besser die Finger von lassen.

                              Kommentar

                              Lädt...
                              X