Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/04/2011, 14:18
afsalas1
 
Fecha de Ingreso: abril-2011
Ubicación: barranquilla atlantico
Mensajes: 8
Antigüedad: 13 años
Puntos: 0
problemas con envio de email

Hola a todos estoy desarollando una pagina en php y debo enviar email a mis usarios para activar su cuenta estoy utilizando el siguiente clase
<?php

class email
{




function email($asunto = "saludar",$direccion = "[email protected]",$mensaje= "hola ana como estas",$remitente= "[email protected]")
{
if(empty($asunto) || empty($direccion) || empty($mensaje) || empty($remitente) ){
return $this->error(1);
}else{
$this->asunto=$asunto;
$this->direcciones=$direccion;
$this->mensaje=$mensaje;
$this->remitente=$remitente;

$this->comprobar($direccion,$remitente);
if(!$this->comprobar){
return $this->error(2);
}//if

} //if-else
} //funcion







function comprobar($direccion= "[email protected]",$remitente= "[email protected]")
{
$this->comprobar=false;
if((@is_array($direccion)) && (@is_array($remitente))){

for($i=0; $i<@count($direccion); $i++){
if ((@strlen($direccion[$i]) >= 3) && (@substr_count($direccion[$i],"@") == 1) && (@substr($direccion[$i],0,1) != "@") && (@substr($direccion[$i],@strlen($direccion[$i])-1,1) != "@") && (@strlen($remitente[$i]) >= 6) && (@substr_count($remitente[$i],"@") == 1) && (@substr($remitente[$i],0,1) != "@") && (@substr($direccion[$i],@strlen($remitente[$i])-1,1) != "@")){
if ((!@strstr($direccion[$i],"'")) && (!@strstr($direccion[$i],"\"")) && (!@strstr($direccion[$i],"\\")) && (!@strstr($direccion[$i],"\$")) && (!@strstr($direccion[$i]," ")) && (!@strstr($remitente[$i],"'")) && (!@strstr($remitente[$i],"\"")) && (!@strstr($remitente[$i],"\\")) && (!@strstr($remitente[$i],"\$")) && (!@strstr($remitente[$i]," "))) {
if ((@substr_count($direccion[$i],".")>= 1) && (@substr_count($remitente[$i],".")>= 1)){
$term = @substr(@strrchr ($direccion[$i], '.'),1);
$term2= @substr(@strrchr ($remitente[$i], '.'),1);
if (@strlen($term)>1 && @strlen($term)<5 && (!@strstr($term,"@")) && @strlen($term2)>1 && @strlen($term2)<5 && (!@strstr($term2,"@"))){
$antes = @substr($direccion[$i],0,@strlen($direccion[$i]) - @strlen($term) - 1);
$antes2 = @substr($remitente[$i],0,@strlen($remitente[$i]) - @strlen($term) - 1);
$caracter = @substr($antes,@strlen($antes)-1,1);
$caracter2= @substr($antes2,@strlen($antes2)-1,1);
if ($caracter != "@" && $caracter != "." && $caracter2 !="@" && $caracter2 !="."){
$this->comprobar= true;
}
}
}
}
}
}

if($this->comprobar){
return $this->comprobar=true;
}else{
return $this->comprobar=false;
}
}else{
if ((@strlen($direccion) >= 3) && (@substr_count($direccion,"@") == 1) && (@substr($direccion,0,1) != "@") && (@substr($direccion,@strlen($direccion)-1,1) != "@") && (@strlen($remitente) >= 6) && (@substr_count($remitente,"@") == 1) && (@substr($remitente,0,1) != "@") && (@substr($direccion,@strlen($remitente)-1,1) != "@")){
if ((!@strstr($direccion,"'")) && (!@strstr($direccion,"\"")) && (!@strstr($direccion,"\\")) && (!@strstr($direccion,"\$")) && (!@strstr($direccion," ")) && (!@strstr($remitente,"'")) && (!@strstr($remitente,"\"")) && (!@strstr($remitente,"\\")) && (!@strstr($remitente,"\$")) && (!@strstr($remitente," "))) {
if ((@substr_count($direccion,".")>= 1) && (@substr_count($remitente,".")>= 1)){
$term = @substr(@strrchr ($direccion, '.'),1);
$term2= @substr(@strrchr ($remitente, '.'),1);
if (@strlen($term)>1 && @strlen($term)<5 && (!@strstr($term,"@")) && @strlen($term2)>1 && @strlen($term2)<5 && (!@strstr($term2,"@"))){
$antes = @substr($direccion,0,@strlen($direccion) - @strlen($term) - 1);
$antes2 = @substr($remitente,0,@strlen($remitente) - @strlen($term) - 1);
$caracter = @substr($antes,@strlen($antes)-1,1);
$caracter2= @substr($antes2,@strlen($antes2)-1,1);
if ($caracter != "@" && $caracter != "." && $caracter2 !="@" && $caracter2 !="."){
$this->comprobar=true;
}
}
}
}
}
if($this->comprobar){
return $this->comprobar=true;
}else{
return $this->comprobar=false;
}
}
}//funcion


function enviar()
{
if(!$this->direcciones || !$this->asunto || !$this->mensaje || !$this->remitente ){
return $this->error(3);
}else{
if(@is_array($this->direcciones) || @is_array($this->asunto) || @is_array($this->mensaje) || @is_array($this->remitente)){
for($i=0;$i<count($this->direcciones);$i++){
if(!@mail($this->direcciones[$i],$this->asunto[$i],$this->mensaje[$i],"FROM : ".$this->remitente[$i]."\r\nReply To: ".$this->remitente[$i]."\r\n")){
return $this->error(4);
}else{
return $this->enviado=true;
}
}//fin for
}else{
if(!@mail($this->direcciones,$this->asunto,$this->mensaje,"FROM : ".$this->remitente."\r\nReply To: ".$this->remitente."\r\n")){
return $this->error(4);
}else{
return $this->enviado=true;
}
}
}
}


function enviado()
{
if(!$this->enviado){
return;
}else{
if($this->enviado){
return "Email(s) enviado";
}else{
return "Email(s) no enviado";
}
}
}


function smtp($server = "127.0.0.1",$port="25",$user="root",$pass="123 ")
{
if(!$this->direcciones || !$this->asunto || !$this->mensaje || !$this->remitente ){
return $this->error(3);
}else{
$fp=fsockopen($server,$port,&$errn,&$error,30) or ($this->error(5));
echo fgets($fp,1024);
fputs($fp,"EHLO 71675615@globalcom\r\n");
fgets($fp,1024);
if($user!="" || $pass!=""){
$auth="AUTH LOGIN\r\n";
fputs($fp,$auth."\r\n") or ($this->error(6));
fgets($fp,1024);
$user=base64_encode($user);
fputs($fp,$user."\r\n") or ($this->error(6));
fgets($fp,1024);
$pass=base64_encode($pass);
fputs($fp,$pass."\r\n") or ($this->error(6));
fgets($fp,1024);
}
if(@is_array($this->direcciones) || @is_array($this->asunto) || @is_array($this->mensaje) || @is_array($this->remitente)){
for ($i=0;$i<count($this->direcciones);$i++){
fputs($fp,"MAIL FROM:".$this->remitente[$i]."\r\n") or ($this->error(6));
fgets($fp,1024);

fputs($fp,"RCPT TO:".$this->direcciones[$i]."\r\n") or ($this->error(6));
fgets($fp,1024);

fputs($fp,"DATA\r\n") or ($this->error(6));
fgets($fp,1024);

fputs($fp,"SUBJECT:".$this->asunto[$i]."\r\n.\r\n") or ($this->error(6));
fgets($fp,1024);

fputs($fp,$this->mensaje[$i]."\r\n.\r\n") or ($this->error(6));
fgets($fp,1024);
}
}else{
fputs($fp,"MAIL FROM:".$this->remitente."\r\n") or ($this->error(6));
fgets($fp,1024);
fputs($fp,"RCPT TO:".$this->direcciones."\r\n") or ($this->error(6));
fgets($fp,1024);
fputs($fp,"DATA\r\n") or ($this->error(6));
fgets($fp,1024);
fputs($fp,"SUBJECT:".$this->asunto."\r\n.\r\n") or ($this->error(6));
fgets($fp,1024);
fputs($fp,$this->mensaje."\r\n.\r\n") or ($this->error(6));
fgets($fp,1024);
}
fputs($fp,"QUIT\r\n") or ($this->error(6));
fgets($fp,1024);
fclose($fp) or ($this->error(7));
}
}//funcion

/*** FIN CLASE ***/
}
/*************** Envio simple via funcion mail()**************************/
$a = "saludar";
$d = "[email protected]";
$m = "hola ana como estas";
$r = "[email protected]";
$mail = new email($a,$d,$m,$r);
$mail->enviar();
echo $mail->errores();//Si exisiten errores los mostrara
echo $mail->enviado();//Muestra un mensaje al enviar el mail


/*************** Envio multiple via funcion mail()**************************/
$a = array("saludar","saludar");
$d = array("[email protected]","[email protected]");
$m = array("hola","hola");
$r = array("[email protected]","[email protected] u.co");
$mail = new email($a,$d,$m,$r);
$mail->enviar();
echo $mail->errores();//Si exisiten errores los mostrara
echo $mail->enviado();//Muestra un mensaje al enviar el mail


/*************** Envio simple via sockets **************************/
$a = "Asunto";
$d = "[email protected]";
$m = "Mensaje";
$r = "[email protected]";
$server = "localhost";//Ip o nombre, o direccion del servidor SMTP
$port = "25";//El puerto a usar
$mail = new email($a,$d,$m,$r);
$mail->smtp($server,$port);
//$mail->smtp($server,$port); En caso de no existir login
echo $mail->errores();//Si exisiten errores los mostrara
echo $mail->enviado();//Muestra un mensaje al enviar el mail



?>
y me aparese el siguiente error
No se puede enviar el/los email(s)No se puede enviar el/los email(s)
Warning: fsockopen() [function.fsockopen]: unable to connect to localhost:25 (Se produjo un error durante el intento de conexión ya que la parte conectada no respondió adecuadamente tras un periodo de tiempo, o bien se produjo un error en la conexión establecida ya que el host conectado no ha podido responder. ) in C:\AppServ\www\class.mail2.php on line 294

Fatal error: Maximum execution time of 30 seconds exceeded in C:\AppServ\www\class.mail2.php on line 130

lei por ahi que tenia que descargar un programa servidor de correo y descarge QK SMTP Server 3 pero no se que debo hacer para poder enviar los mail espero me puedan ayudar por que llevo muchos dias investigando sobre esto y nada