Necesitamos urgentemente el código fuente de php pop3 para recibir correos electrónicos (puede recibir archivos adjuntos), y el código para recibir solo archivos adjuntos también está disponible.
if ($email_inc) retorno
$email_inc= "definido"
define( "smtpport", 25);
class pop3 {
var $subject;
var $from_email; // Dirección del remitente
var $from_name; // Nombre del remitente
var $to_email; // Dirección del destinatario
var $to_name;
var $body; // Contenido del correo electrónico
var $filename; / Nombre de archivo
var $socket; // Socket actual
var $line
var $status;
p>función; pop3_open($ servidor, $puerto)
{
$this->socket = fsockopen($servidor, $puerto
if ($this-); >socket <= 0){
return false
}
$this->line = fgets($this-> socket, 1024); /p>
$this->status["lastresult"] = substr($this->line, 0, 1);
$this->status["lastresult"] = substr( $this->line, 0, 1);
$this->status["lastresulttxt"] = substr($this->line, 0, 1024); if ($this->status["lastresult"] <> "+") devuelve falso
devuelve verdadero
}
función pop3_user ($ usuario)
{
if ($this->socket < 0){
return false
}
fputs ($this->socket, "usuario $this->userrn");
$this->line = fgets($this->socket, 1024)
<; p>$this->status[ "lastresult"] = substr($this->line, 0, 1$this->status[ "lastresulttxt"] = substr($this->); línea, 0, 1024);
if ($this->status[ "lastresult"] <> "+") devuelve falso
devuelve verdadero
}
función pop3_pass( $pass)
{
fputs($this->calcetín
et , "pasar $passrn");
$this->line = fgets($this->socket, 1024);
$this->status[ "lastresult"] = substr($this->line, 0, 1);
$this->status[ "lastresulttxt"] = substr($this->line, 0, 1024);
if ($this->status[ "lastresult"] <> "+") devuelve 0
devuelve 1
}
función; pop3_stat()
{
fputs($this->socket, "statrn"
$this->line = fgets($this->); socket, 1024);
$this->status[ "lastresult"] = substr($this-> línea, 0, 1); "lastresulttxt"] = substr($this->line, 0, 1024
if ($this->status[ "lastresult"] <> "+") devuelve 0;
if (!eregi( "+ok (. *) (. *)", $this->line, $regs))
return 0
return $; regs[1];
}
función pop3_list()
{
fputs($this->.socket, "listrn ");
$this->line = fgets($this->socket, 1024);
$this->status[ "lastresult"] = substr($this- >línea, 0, 1);
$this->status[ "lastresulttxt"] = substr($this-> línea, 0, 1024); this->status[ "lastresult"] <> "+") devuelve 0;
$i = 0;
mientras (substr($this->line = fgets($ this->socket, 1024), 0, 1) <> ".")
{
$artículos[$i] = $this->line
$i++;
}
$artículos["count"] = $i; }
función pop3_retr($nr)
{
fputs($this->socket, "retr $nrrn"); >$esta->línea = fgets($esta->socket, 1
024);
$this->status[ "lastresult"] = substr($this->line, 0, 1);
$this-> ($this->line, 0, 1024);
if ($this->status[ "lastresult"] <> "+") devuelve 0
mientras (substr; ($this->line = fgets($this->socket, 1024), 0, 1) & lt;> ".")
{
$datos[$i ] = $esta->línea
$i++;
}
$datos[ "recuento"] = $i; >retornar $datos;
}
función pop3_dele( $nr)
{
fputs($this->socket, " eliminar $nrrn");
$this->line = fgets($this->socket, 1024);
$this->status[ "lastresult"] = substr( $this->line, 0, 1);
$this->status[ "lastresulttxt"] = substr($this->line, 0, 1024); if ($this->status[ "lastresult"] <> "+") devuelve 0
devuelve 1
}
función pop3_quit();
{
fputs($this-& gt;socket, "quitrn");
$this->line = fgets($this->socket) , 1024);
$this->status[ "lastresult"] = substr($this-> línea, 0, 1);
$this->status[ " lastresulttxt"] = substr($this->line, 0, 1024);
if ($this->status[ "lastresult"] <> "+") devuelve 0;
return 1;
}
}
class smtp {
var $subject; // cadena del asunto del correo electrónico
p>p>
var $fromname; // nombre del remitente de la cadena (opt)
var $toname; // nombre del destinatario de la cadena (opt)
var $ cuerpo; // copia del cuerpo de la cadena
var $adjunto;
var $tipo de archivo adjunto
var $socket; línea;
var $tipo de archivo adjunto;
var $socket
var $línea
p>
var $estado;
función smtp($servidor = "localhost",$ puerto = smtpport)
{
return $this- >open($servidor, $puerto);
}
}
función smtpmail($fromemail, $fromname, $toemail, $toname, $asunto , $cuerpo, $attachment=null, $attachmenttype= "texto")
{
$this->subject = $subject;
$this- >toname = $ toname;
$this->fromname = $fromname;
$this->body = $body
$this->adjunto; = $adjunto
$this->.attachmenttype = $attachmenttype
if ($this->helo() == false){
return; falso;
}
if ($this->mailfrom($ fromemail) == false){
return false; }
if ($this->rcptto($toemail) == false){
return false
}
si ($this->body() == false){
return false
}
if ($this->quit() == false; ){
devuelve falso
}
}
}
función abierta($servidor, $ puerto)
{
$this->socket = fsockopen($servidor, $puerto
if ($this->socket < 0) return); false;
$this->line = fgets($this->socket, 1024
$this-> >línea, 0, 1);
$this-> ; estado["lastresulttxt"] = substr($this->línea, 0, 1024); this->status["lastresult"] <> "2") devuelve falso
devuelve verdadero
}
función helo()
{
if (fputs($this->socket, "helorn") < 0 ){
return false
} p>
si ($this->estado
s[ "lastresult"] <> "2") devuelve falso
}
$this->line = fgets($this->socket, 1024
$this->status[ "lastresult"] = substr($this->line, 0, 1);
$this->.status[ "lastresulttxt"] = substr($ this->line, 0, 1024);
if ($this->status[ "lastresult"] <> "2") devuelve falso
devuelve verdadero p> p>
}
función ehlo()
{
/* Bien, usemos "helo" por ahora.
Hasta que necesitemos
funcs adicionales [unk]
*/
if(fputs($this->socket, "helo localhostrn")<0){
devuelve falso;
}
$this->line = fgets($this->socket, 1024
$); this->status[ "lastresult"] = substr($this->line, 0, 1
$this-& gt; , 0, 1024);
if ($this->status[ "lastresult"] <> "2") devuelve falso
devuelve verdadero
}
función mailfrom($fromemail)
{
if (fputs($this->socket, "correo desde: <$fromemail>rn" ) < ;0){
return false
}
$this->line = fgets($this->socket, 1024); p> p>
$this->status[ "lastresult"] = substr($this->line, 0, 1
$this-> substr( $this->line, 0, 1024);
if ($this->status[ "lastresult"] <> "2") devuelve falso
devuelve verdadero; ;
}
función rcptto($toemail)
{
if (fputs($this->socket, "rcpt a . < $toemail>rn")<0){
return false;
}
$this->line = fgets($this->socket). , 1024 );
$this->status[ "lastresult"] = substr($this->line, 0, 1);
$this-> lastresulttxt" ] = substr($this->line, 0, 1024);
if ($this-> ;status[ "lastresult"] <> "2") devuelve falso;
devuelve verdadero;
}
cuerpo de función()
{
$tamaño de archivo = 0; p> $ adjunto = nulo;
$fp = nulo;
$buffer = sprintf( "de: %srnto:%srnsubject:%srn",
$this->fromname, $this->toname, $this-& gt;subject);
if(fputs($this->socket, "datarn")<0){
devuelve falso
}
$this->line = fgets($this->.socket, 1024
$this->); estado[ "lastresult"] = substr($this->line, 0, 1);
$this->status[ "lastresulttxt"] = substr($this->line, 0, 1024) ;
if ($this->status[ "lastresult"] <> "3") devuelve falso
if (fputs($this->socket, $buffer)< ;0){
return false
}
if ($this->adjunto == null){
if ( fputs($this->socket, "mime-version: 1.0rncontent- type: text/plain; charset=iso-8859-1rncontent-transfer-encoding: 7bitrnrn")<0){
Devuelve false
}
if(fputs($this-& gt;socket, "$this->bodyrnrn")<0){
devuelve falso;
}
if(fputs($this->socket, ".rn")<0){
devuelve falso; >}