I am a beginner in PHP programming and i have a problem sending email using localhost (Wamp Server) on windows, I looked dozen of answers on this problem but still unable to solve my problem,Is there any problem in my code?
Here is my code
<?php
/**
* Created by PhpStorm.
* User: Farrukh
* Date: 2/19/2016
* Time: 5:09 PM
*/
require "PHPMailer-master/PHPMailerAutoload.php";
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Username = 'myemail';
$mail->Password = 'mypassword';
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->From = 'farrukh@gmail.com';
$mail->FromName = 'FMailer';
$mail->addAddress('myfrien@gmail.com', 'Farrukh');
$mail->WordWrap = 50;
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->isHTML(true);
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';
?>