PHP SMTP mail function



PHP send mail or notification in SMTP SERVER used


<?php
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/>&nbsp;&nbsp;<br/><b>Your Username is : </b>$infoemail<br/>&nbsp;<b>Your Password is : </b>$infopass<br/>&nbsp;&nbsp;<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";
}
   
?>
Share on Google Plus

About quora Questions & Answers A-Z

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment