Ver Mensaje Individual
  #2 (permalink)  
Antiguo 10/11/2010, 03:31
vall-k
 
Fecha de Ingreso: abril-2005
Mensajes: 29
Antigüedad: 19 años
Puntos: 1
Respuesta: Enviar con ubuntu server mails desde SMTP de gmail

Hola de nuevo. Por si a alguien le interesa ahí va mi auto-respuesta:

He conseguido utilizar el smtp de gmail con la clase PHPMailer y el siguiente código:

<?php

require_once 'class.phpmailer.php';

$mail = new PHPMailer ();

$mail -> From = "[email protected]";
$mail -> FromName = "Foo";
$mail -> AddAddress ("[email protected]");
$mail -> Subject = "Test";
$mail -> Body = "<h3>De GMail!</h3>";
$mail -> IsHTML (true);

$mail->IsSMTP();
$mail->Host = 'ssl://smtp.gmail.com';
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username = '<user>@gmail.com';
$mail->Password = '******';

if(!$mail->Send()) {
echo 'Error: ' . $mail->ErrorInfo;
}
else {
echo 'Mail enviado!';
}

?>

Ha funcionado genial y he podido enviar a hotmail y yahoo sin problemas.

Gracias y ya pueden cerrar el tema.