Sunday, 11 August 2013

unable to send mail in php using mailer class

unable to send mail in php using mailer class

Today i was doing some mailing stuff in the php, I found that there are
two methods for that one is the simple mail function provided by the Php
and the second i found on the internet it was about using the PHP mailer
class from the site https://github.com/PHPMailer/PHPMailer. the problem is
that which i run my program than the mail is not being sent. Let's have a
look at the code
<?php
include'PHPMailer-master/class.phpmailer.php'; // this is a class which i
downloaded from the above mentioned link
//Create the instanceof the php mailer class
$mail= new PHPMailer();
$mail->IsSMTP();
$mail->Host='smtp.gmail.com';
$mail->SMTPAuth=true;
$mail->Username='**********@gmail.com';
$mail->Password='**********';
$mail->SMTPSecure='ssl';
$mail->SMTPKeepAlive=true;
$mail->Port='587';
$mail->Mailer="smtp";
$mail->From='***********@gmail.com';
$mail->AddAddress('********@gmail.com');
$mail->IsHTML(true);
$mail->Subject='the second mail';
//check
if ($mail->Send())
{
echo "mail send sucessfully";
}
else
echo "sending failed";
?>
now when i execute it. the result is Sending failed.Please let me know the
problem

No comments:

Post a Comment