Ich möchte einige Methoden zum Schreiben des Prozessors für eingehende E-Mails beschreiben. Ich musste solche Manipulationen nutzen, um Analysieren von E-Mails aus verschiedenen Quellen. Dies kann nützlich sein, um Ihr eigenes Spam-Filter-System zu schreiben, Anrufbeantworter oder Ticketsystem zum Empfang von Bewerbungen per E-Mail.
Um den E-Mail-Parser-Algorithmus zu implementieren, benötigen wir
- Verbindung und Anmeldung mit E-Mail-Server
- Zählen der Anzahl eingehender Briefe
- E-Mail vom Server mit POP3-Protokoll abrufen
- verarbeiten Sie die E-Mail-Header und den Text und führen Sie Parsing durch
- … Implementierung zusätzlicher Maßnahmen
Okay, es gibt eine ganz spezifische Aufgabe für PHP-Codierung, Wir benötigen also Hosting, das externe Verbindung unterstützt. I do not propose to write decision entirely because much has been realized by talented programmers already. Zum Beispiel, you can take a ready module which will allow accept e-mails from a remote server.
Thank’s to Manuel Lemos and his module (php class) which named pop3.php.
To connect that class to your code, you just need to use include or require command: require(“pop3.php”);
require("pop3.php"); $hostname = 'pop3.mail.com'; $port = '110'; $user = 'pop3-username'; $accesscode = 'pop3-password'; // Create the class connection $pop3_connection=new pop3_class; // Specify the hostname $pop3_connection->hostname=$hostname; $result=$pop3_connection->Open(); // We are trying to open connection and display the result echo $result; // Trying to logon and display the error if any appear $error=$pop3_connection->Login($Benutzer,$accesscode,$apop); If ($Fehler<>'Password error: Logon failure: unknown user name or bad password.') {echo $error; exit;} // Now get the statistic how many emails are stored and the size of them $result=$pop3_connection->Statistics($Nachrichten, $size); Echo "$hostname contains $Nachrichten von $size bytes."; //..... There we can receive e-mails in the cycle and parse them.... // // If nothing to do - we can close the connection $error=$pop3_connection->Close(); // echo $error; ?>
Now we know how to connect and log-on to the POP3 server and how to request the number of Inbox e-mails and them sizes. Nächster, we should receive each e-mail and parse the headers and body array.
TO BE CONTINUED
Great, that is working, what now? How to receive the e-mail? How to write e-mail parser? Continue please, great post!
Fantastic Post. I have read many posts on this subject and you done the best job. Keep it up!
You can not believe just how long ive been googling because of this. Through seven pages of Digg results with out finding anything. 1 search on Msn. There this is… Gotta start using this more often ebrantley@KC.RR.com