Usando el phpMailer (http://sourceforge.net/project/showfile ... _id=252700) y el siguiente código (también viene un ejemplo) pero para los que prefieren copiar y pegar aquí les va:
Código: Seleccionar todo
require_once 'class.phpmailer.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = 'USUARIO@gmail.com';
$mail->Password = 'PASSWORD';
$mail->From = "USUARIO@gmail.com";
$mail->FromName = "Tu nombre";
$mail->Subject = "Asunto";
$mail->Body = "Mensaje";
$mail->AddAddress("example@domain.com", "Juan Pérez");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
Si les aparece el error "Unable to find the socket transport "ssl" - did you forget to enable it "ssl " - did you forget to enable it when you configured PHP?" tienen que ir al php.ini y descomentan
Código: Seleccionar todo
extension=php_openssl.dll
Si quieren una clase exclusiva pueden leer este post: UPDATE: Send email with PHP and GMail hosted for your domain