Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/02/2011, 05:57
Acelsp
 
Fecha de Ingreso: mayo-2008
Mensajes: 70
Antigüedad: 18 años, 4 meses
Puntos: 0
Problema con PHPMAiler y 1and1

Hola, estoy intentando configurar PHPMailer para enviar mails autenticados con 1and1, pero me da errores. Este es el código

Código PHP:
        require_once('PHPMailer/class.phpmailer.php');
        
$mail = new PHPMailer();
        
$body = "Aqui va el body";
        
$mail->IsSMTP(); // telling the class to use SMTP
        
$mail->Host = "smtp.1and1.com"; // SMTP server
        //$mail->SMTPAuth = true; // enable SMTP authentication
        //$mail->Port = 587; // set the SMTP
        
$mail->Username = "[email protected]";  //username
        
$mail->Password = "mipassword"; //password
        
$mail->SetFrom('[email protected]', 'Nombre'); 
        
$mail->AddReplyTo('[email protected]', 'Nombre');
        
$mail->Subject = "Subject";
        
$mail->AltBody = "Opcional"; // optional, comment out and test
        
$mail->MsgHTML($body);
        
$mail->AddAddress('[email protected]', 'Destinatario');
        
        if(!
$mail->Send()) { 
            echo 
"Mailer Error: " . $mail->ErrorInfo; 
        } else { 
            echo 
"Message sent!"; 
        } 
Tal y como está ahora sí funciona, pero si quito los comentarios a las dos líneas de autenticación me da un error y no envía el mail.

Alguien me puede echar una mano?