Lire sur le contenu d'une socket pop3 - PHP - Programmation
Marsh Posté le 23-04-2003 à 14:03:28
Bonjour, J'ai une question au sujet de la lecture dune socket. J'ouvre une communication a travers une socket (port 110) comme ceci : <? $host = "pop.monfai.fr"; $port = "110"; $socket = fsockopen($host, $port, &$errno, &$errstr); if ($socket) { print(fgets($socket, 1024)); echo "<br>"; } $write = fputs($socket, "user moncompte" ); $write = fputs($socket, "\r\n" ); if ($write) { print(fgets($socket, 1024)); echo "<br>"; } $write = fputs($socket, "pass monpass" ); $write = fputs($socket, "\r\n" ); if ($write) { print(fgets($socket, 1024)); echo "<br>"; } $write = fputs($socket, "STAT" ); $write = fputs($socket, "\r\n" ); if ($write) { print(fgets($socket, 1024)); echo "<br>"; } $write = fputs($socket, "TOP 1 0" ); $write = fputs($socket, "\r\n" ); // Le pb commence ici if ($write) { $read = fputs($socket, "TOP 1 0" ); print(fgets($socket, 1024)); echo "<br>"; } // Jusque là /* $write = fputs($socket, "LIST" ); $write = fputs($socket, "\r\n" ); if ($write) { print(fgets($socket, 1024)); print "<br>"; } /* $write = fputs($socket, "from: moncompte" ); $write = fputs($socket, "\r\n" ); $write = fputs($socket, "to: unautrecompte" ); $write = fputs($socket, "\r\n" ); $write = fputs($socket, "subject: ESSAI" ); $write = fputs($socket, "\r\n" ); $write = fputs($socket, "Ceci est un test" ); $write = fputs($socket, "\r\n" ); $write = fputs($socket, "." ); $write = fputs($socket, "\r\n" ); if ($write) { print(fgets($socket, 1024)); print "<br>"; } $write = fputs($socket, "quit" ); $write = fputs($socket, "\r\n" ); if ($write) { print(fgets($socket, 1024)); } */ fclose($socket); ?> Il m'affiche ça : +OK <5154.1051099282@pop1-1.free.fr> +OK +OK +OK 2 6936 +OK 3402 octets pas plus, j'aimerai qu'il m'affiche tous les message (ou du moins les entetes) Y a t'il une soluce a sa ? Merci
Make sure you enter the(*)required information where indicate.HTML code is not allowed
Marsh Posté le 23-04-2003 à 14:03:28
Bonjour,
J'ai une question au sujet de la lecture dune socket.
J'ouvre une communication a travers une socket (port 110) comme ceci :
<?
$host = "pop.monfai.fr";
$port = "110";
$socket = fsockopen($host, $port, &$errno, &$errstr);
if ($socket) {
print(fgets($socket, 1024));
echo "<br>";
}
$write = fputs($socket, "user moncompte" );
$write = fputs($socket, "\r\n" );
if ($write) {
print(fgets($socket, 1024));
echo "<br>";
}
$write = fputs($socket, "pass monpass" );
$write = fputs($socket, "\r\n" );
if ($write) {
print(fgets($socket, 1024));
echo "<br>";
}
$write = fputs($socket, "STAT" );
$write = fputs($socket, "\r\n" );
if ($write) {
print(fgets($socket, 1024));
echo "<br>";
}
$write = fputs($socket, "TOP 1 0" );
$write = fputs($socket, "\r\n" );
// Le pb commence ici
if ($write) {
$read = fputs($socket, "TOP 1 0" );
print(fgets($socket, 1024));
echo "<br>";
}
// Jusque là
/*
$write = fputs($socket, "LIST" );
$write = fputs($socket, "\r\n" );
if ($write) {
print(fgets($socket, 1024));
print "<br>";
}
/*
$write = fputs($socket, "from: moncompte" );
$write = fputs($socket, "\r\n" );
$write = fputs($socket, "to: unautrecompte" );
$write = fputs($socket, "\r\n" );
$write = fputs($socket, "subject: ESSAI" );
$write = fputs($socket, "\r\n" );
$write = fputs($socket, "Ceci est un test" );
$write = fputs($socket, "\r\n" );
$write = fputs($socket, "." );
$write = fputs($socket, "\r\n" );
if ($write) {
print(fgets($socket, 1024));
print "<br>";
}
$write = fputs($socket, "quit" );
$write = fputs($socket, "\r\n" );
if ($write) {
print(fgets($socket, 1024));
}
*/
fclose($socket);
?>
Il m'affiche ça :
+OK <5154.1051099282@pop1-1.free.fr>
+OK
+OK
+OK 2 6936
+OK 3402 octets
pas plus, j'aimerai qu'il m'affiche tous les message (ou du moins les entetes)
Y a t'il une soluce a sa ?
Merci
---------------
Linuxois1 ex- Linuxois pour perte de mot de passe et @ adresse mail n'existant plus.