Ver Mensaje Individual
  #6 (permalink)  
Antiguo 28/02/2009, 13:05
lizardopc
 
Fecha de Ingreso: diciembre-2005
Mensajes: 50
Antigüedad: 18 años, 4 meses
Puntos: 0
Respuesta: Como recibir los emails con php

para eso usaria un mail pipe, algo como el codigo de abajo,

para que funcione tienes que hacer un redireccionamiento del correo hacia tu programa php.


#!/usr/bin/php
<?php
// script chmoded to 755
// alias: [email protected]: ¦/home/erik/404pipe.php

// read from stdin
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);

// handle email
$lines = explode("\n", $email);

// empty vars
$from = "";
$subject = "";
$headers = "";
$message = "";
$splittingheaders = true;

for ($i=0; $i<count($lines); $i++) {
if ($splittingheaders) {
// this is a header
$headers .= $lines[$i]."\n";

// look out for special headers
if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) {
$subject = $matches[1];
}
if (preg_match("/^From: (.*)/", $lines[$i], $matches)) {
$from = $matches[1];
}
} else {
// not a header, but message
$message .= $lines[$i]."\n";
}

if (trim($lines[$i])=="") {
// empty line, header section has ended
$splittingheaders = false;
}
}

?>