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------------------------------------------ Index ------------------------------
<html>
<head>
<meta charset="utf-8">
<?php
include_once('Envio_Correo.php');
?>
</head>
<body>
<form action="" method="POST">
<!-- <ul>
<li> -->
<label> Emails </label>
<input type="text" name="texto" ></input>
<!-- </li>
<li> -->
<label> Asunto </label>
<input type="text" name="asunto"></input>
<!-- </li>
<li>-->
<label> Mensaje </label>
<input type="text" name="mensaje"></input>
<input type="submit" name="btn_enviar" value="enviar" ></input>
<!-- </li>
</ul> -->
</form>
</body>
<?php
$email = new Envio_Correo();
if(isset($_POST['btn_enviar'])){ $correos = $_POST["texto"];
$email->Agregar_direcciones($correos);
$asunto = $_POST['asunto'];
$msn = $_POST['mensaje'];
$email->Mensaje_asunto($asunto);
$email->Mensaje_factura($msn);
$email->Enviar();
echo $email->debug();
echo var_dump($email->Mostrar_destinatarios()); // echo var_dump($email->Listar_errores());
}
?>
</html>
-----------------------------------------------------------------------
script Envio_Correo
<?php
require "class.phpmailer.php";
//include_once('class.smtp.php');
class Envio_Correo {
public $array_direcciones;
public $error;
public $mail;
public function __construct(){
//$this->array_direcciones = Array();
$this->mail = new phpmailer
(); //$this->mail;
//$array_direcciones = array();
$this->mail->PluginDir = ""; //"includes/";
$this->mail->Mailer = "smtp";
$this->mail->Host = "mx1.hostinger.co";
$this->mail->SMTPAuth = true;
$this->mail->Password = "xxxx";
$this->mail->Port = 25;
$this->mail->From = "";
$this->mail->FromName = "Web Ecommerce..";
$this->mail->AltBody ="Mensaje de prueba mandado con phpmailer en formato texto";
$this->mail->Timeout=10;
$this->mail->SMTPDebug = 1;
// $this->mail->SMTPKeepAlive = true;
// $this->mail->SmtpClose();
// $this->mail->isSMTP();
}
public function debug(){
return $this->mail->SMTPDebug;
}
public function Mostrar_destinatarios(){
return $this->array_direcciones;
}
public function Mensaje_asunto($msg){
$this->mail->Subject = $msg;
}
public function Mensaje_factura($msg){
$this->Body = $msg;
}
public function Mensaje_activacion($msg){
$this->Body = $msg;
}
public function Mensaje_promosional($msg){
$this->Body = $msg;
}
public function Mensaje_informativo($msg){
$this->Body = $msg;
}
public function Agregar_direcciones($direcciones){
$this->array_direcciones[] = $direcciones ;
}
public function Enviar(){
// reset($array_direcciones);
foreach($this->Mostrar_destinatarios() as $array) {
$this->mail->AddAddress($array);
$exito = $this->mail->Send();
$intentos = 1;
while((!$exito)&&($intentos<5)&&($this->mail->ErrorInfo!="SMTP Error: Data not accepted")){
echo $this->mail->ErrorInfo;
$exito = $this->mail->Send();
$intentos=$intentos+1;
}
if ($this->mail->ErrorInfo=="SMTP Error: Data not accepted") {
$exito=true;
echo $this->mail->ErrorInfo;
}
if(!$exito){
echo "Problemas enviando correo electrónico a ".$array;
echo "<br/>".$this->mail->ErrorInfo;
}else{
$mensaje="<p>Has enviado un mensaje a:<br/>";
$mensaje.=$array." ";
$mensaje.="</p>";
echo $mensaje;
}
$this->mail->ClearAddresses();
}
}
}
?>