Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/12/2014, 15:07
andres18281
 
Fecha de Ingreso: febrero-2013
Ubicación: Cali Colombia
Mensajes: 118
Antigüedad: 11 años, 1 mes
Puntos: 0
Error 500 phpmailer

Saludos, he estado leyendo algunos post sobre phpmailer pero no logro dar con la solucion, en un servidor de hostinger cree una web y un correo en el cual he puesto en mi archivo de abajo y lo subi pero siempre me muestra el error 500 Internal server Error sin embargo si lo ejecuto en modo local asi con el from y cuenta de hostinger si permite enviar correos.

Les agradezco la colaboracion

Código PHP:
Ver original
  1. ------------------------------------------ Index ------------------------------
  2. <html>
  3. <head>
  4.     <meta charset="utf-8">
  5. <?php
  6. include_once('Envio_Correo.php');
  7. ini_set("display_errors", 1);
  8.  ?>
  9. </head>
  10.     <body>
  11.         <form action="" method="POST">
  12.        <!-- <ul>
  13.             <li> -->
  14.         <label> Emails </label>
  15.         <input type="text" name="texto" ></input>
  16.            <!-- </li>
  17.             <li> -->        
  18.         <label> Asunto </label>
  19.         <input type="text" name="asunto"></input>
  20.            <!-- </li>
  21.             <li>-->        
  22.         <label> Mensaje </label>
  23.         <input type="text" name="mensaje"></input>
  24.          <input type="submit" name="btn_enviar" value="enviar" ></input>
  25.          <!-- </li>        
  26.         </ul> -->        
  27.         </form>
  28.     </body>    
  29. <?php
  30.             $email = new Envio_Correo();
  31.             if(isset($_POST['btn_enviar'])){
  32.                 $correos = $_POST["texto"];
  33.                 $email->Agregar_direcciones($correos);
  34.                 $asunto = $_POST['asunto'];
  35.                 $msn = $_POST['mensaje'];
  36.                 $email->Mensaje_asunto($asunto);
  37.                 $email->Mensaje_factura($msn);    
  38.                 $email->Enviar();
  39.                 echo $email->debug();  
  40.                 echo var_dump($email->Mostrar_destinatarios());
  41.               //  echo var_dump($email->Listar_errores());          
  42.             }          
  43.         ?>
  44.  
  45. </html>
  46. -----------------------------------------------------------------------
  47.                                         script Envio_Correo
  48. <?php
  49. ini_set("display_errors", 1);
  50. require "class.phpmailer.php";
  51. //include_once('class.smtp.php');
  52.     class Envio_Correo {
  53.      
  54.        public $array_direcciones;
  55.        public $error;
  56.        public $mail;
  57.        public function __construct(){
  58.         //$this->array_direcciones =  Array();
  59.         $this->mail = new phpmailer();
  60.         //$this->mail;
  61.         //$array_direcciones =  array();
  62.         $this->mail->PluginDir = ""; //"includes/";
  63.         $this->mail->Mailer = "smtp";
  64.         $this->mail->Host = "mx1.hostinger.co";
  65.         $this->mail->SMTPAuth = true;
  66.        $this->mail->Username = "[email protected]";
  67.        $this->mail->Password = "xxxx";
  68.         $this->mail->Port = 25;
  69.         $this->mail->From = "";
  70.         $this->mail->FromName = "Web Ecommerce..";
  71.         $this->mail->AltBody ="Mensaje de prueba mandado con phpmailer en formato texto";
  72.         $this->mail->Timeout=10;
  73.         $this->mail->SMTPDebug  = 1;
  74.        // $this->mail->SMTPKeepAlive = true;
  75.       //  $this->mail->SmtpClose();
  76.       //  $this->mail->isSMTP();
  77.        }
  78.        public function debug(){
  79.           return $this->mail->SMTPDebug;
  80.        }
  81.        public function Mostrar_destinatarios(){
  82.           return $this->array_direcciones;
  83.        }
  84.         public function Mensaje_asunto($msg){
  85.             $this->mail->Subject = $msg;
  86.         }
  87.  
  88.         public function Mensaje_factura($msg){
  89.             $this->Body = $msg;
  90.         }
  91.      
  92.         public function Mensaje_activacion($msg){
  93.             $this->Body = $msg;
  94.         }
  95.  
  96.         public function Mensaje_promosional($msg){
  97.             $this->Body = $msg;
  98.         }
  99.  
  100.         public function Mensaje_informativo($msg){
  101.             $this->Body = $msg;
  102.         }
  103.  
  104.         public function Agregar_direcciones($direcciones){
  105.  
  106.            $this->array_direcciones[] = $direcciones ;
  107.         }
  108.  
  109.         public function Enviar(){
  110.          
  111.         //  reset($array_direcciones);
  112.           foreach($this->Mostrar_destinatarios() as $array) {
  113.             $this->mail->AddAddress($array);
  114.             $exito = $this->mail->Send();
  115.             $intentos = 1;
  116.             while((!$exito)&&($intentos<5)&&($this->mail->ErrorInfo!="SMTP Error: Data not accepted")){
  117.               sleep(5);
  118.               echo $this->mail->ErrorInfo;
  119.               $exito = $this->mail->Send();
  120.               $intentos=$intentos+1;      
  121.             }
  122.             if ($this->mail->ErrorInfo=="SMTP Error: Data not accepted") {
  123.               $exito=true;
  124.               echo $this->mail->ErrorInfo;
  125.             }
  126.             if(!$exito){
  127.               echo "Problemas enviando correo electrónico a ".$array;
  128.               echo "<br/>".$this->mail->ErrorInfo;
  129.             }else{
  130.               $mensaje="<p>Has enviado un mensaje a:<br/>";
  131.               $mensaje.=$array." ";
  132.               $mensaje.="</p>";
  133.                 echo $mensaje;
  134.             }
  135.               $this->mail->ClearAddresses();
  136.           }
  137.       }
  138.  
  139.    
  140.   }
  141.      
  142.  
  143. ?>