send php mail using gmail smtp server

We just have to have a gmail account to send email in php in this way.

download phpMailer from http://sourceforge.net/
Only 3 php files were used according to my code.

-class.phpmailer.php (Got from phpmailer)
-class.smtp.php (Got from phpmailer)
-mail.php

mail.php

<?php

require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP(true);
$mail->Host = 'ssl://smtp.gmail.com:465';
$mail->SMTPAuth = true;

//gmail user name
$mail->Username = 'nimesha.priyangi@gmail.com';

//gmail password
$mail->Password = 'mypassword';

$mail->From     = "from@example.com";

//mail goes to whom
$mail->AddAddress("nimesha@test.com");

$mail->Subject  = "PHP Mail Using Gmail/PHPMailer";
$mail->Body     = "Hi! \n\n This is the test mail sent using phpMailer/Gmail.";

if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
?>

Thats all... :)