PHP send mail or notification in SMTP SERVER used
include("connection.php");
include "classes/class.phpmailer.php";
$email=$_POST['forgot'];
$sql="select usernm,emailaddress,userpass from `usermst` where `emailaddress`='".$email."'";
$query=mysql_query($sql) or die(mysql_error());
$res=mysql_fetch_array($query);
$infoemail=$res['emailaddress'];
$infopass=$res['userpass'];
$username=$res['usernm'];
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "jaydeep.king25@gmail.com";
$mail->Password = "**************";
$mail->SetFrom("jaydeep.king25@gmail.com");
$mail->Subject = "subject";
$mail->Body = "<b>Dear $username,</b><br/> <br/><b>Your Username is : </b>$infoemail<br/> <b>Your Password is : </b>$infopass<br/> <br/>Thanks<br/>Support Team<br/>Student Management System";
$mail->AddAddress($infoemail);
if(!$mail->Send()){
echo "Mailer Error: " . $mail->ErrorInfo;
}
else{
echo "Message has been sent";
}
?>
0 comments:
Post a Comment