Use phpmailer with gmail server to send the mail - LAMP

1)/etc/php5/apache2/php.ini

openssl enabled?

2) Download PHPMailer

class.phpmailer.php:


 public $Host          = 'smtp.gmail.com';
  public $Port          = 465;

3) create sendmail.php




set_time_limit(2000);
include("PHPMailer/class.phpmailer.php");
$mail= new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->CharSet = "utf-8";

$mail->Username = "";
$mail->Password = "";
$mail->From = "";
$mail->FromName = "";
$mail->Subject ="";
$mail->Body = "";
$mail->IsHTML(true);//true or false
$mail->AddAddress("");
if(!$mail->Send()){
     echo "ERROR: " . $mail->ErrorInfo;
}else{
     echo "
SUCCESS
";
}
?>