include($_SERVER['DOCUMENT_ROOT'].'/DataBase/config.php');
require("email_infrastructure/PHPMailer/class.phpmailer.php");
$logo_sql="SELECT * FROM `crm_software_settings` where config_key='site_logo'";
$logo_query=mysqli_query($con, $logo_sql);
$logo_data=mysqli_fetch_array($logo_query);
$site_logo=$logo_data['config_value'];
if(isset($_POST['submit']))
{
$email=$_POST["email"];
function data_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
if (empty($email)) {
$emailErr = "Plese enter your email";
} else {
// check if e-mail address is well-formed
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Kindly double check your email and try again";
}
$email = data_input($_POST["email"]);
$sql="select `email_address`, `firstname` from `lsm_login_details` where `email_address`='$email'";
$sql_query=mysqli_query($con, $sql);
$num=mysqli_num_rows($sql_query);
if($num > 0)
{
$sql_result=mysqli_fetch_array($sql_query);
$register_email=$sql_result['email_address'];
$fname=$sql_result['firstname'];
# generate authentication number
$authentication_number=rand(1000,10000);
$authentication_number_sql="Update `lsm_login_details` set `authentication_number`='$authentication_number' where `email_address`='$register_email'";
$authentication_number_query=mysqli_query($con, $authentication_number_sql);
if($authentication_number_query){
#-------start-mail function--------#
$to=$register_email;
$template_subject = "Primevendors - Reset Password";
$template_body = "
";
// Modify the path in the require statement below to refer to the
// location of your Composer autoload.php file.
// Instantiate a new PHPMailer
$mail = new PHPMailer;
// Tell PHPMailer to use SMTP
$mail->isSMTP();
// Replace
[email protected] with your "From" address.
// This address must be verified with Amazon SES.
$mail->setFrom($from_email, $template_subject);
// Replace
[email protected] with a "To" address. If your account
// is still in the sandbox, this address must be verified.
// Also note that you can include several addAddress() lines to send
// email to multiple recipients.
//$mail->addAddress('
[email protected]', 'Recipient Name');
$mail->AddAddress($to);
//$mail->AddAddress('
[email protected]');
// Replace smtp_username with your Amazon SES SMTP user name.
$mail->Username = $smtp_username;
// Replace smtp_password with your Amazon SES SMTP password.
$mail->Password = $smtp_password;
// Specify a configuration set. If you do not want to use a configuration
// set, comment or remove the next line.
$mail->addCustomHeader('X-SES-CONFIGURATION-SET', 'ConfigSet');
// If you're using Amazon SES in a region other than US West (Oregon),
// replace email-smtp.us-west-2.amazonaws.com with the Amazon SES SMTP
// endpoint in the appropriate region.
$mail->Host = $smtp_host_url;
// The subject line of the email
$mail->Subject = $template_subject;
// The HTML-formatted body of the email
$mail->Body = $template_body;
// Tells PHPMailer to use SMTP authentication
$mail->SMTPAuth = true;
// Enable TLS encryption over port 587
$mail->SMTPSecure = 'tls';
$mail->Port = $smtp_port;
// Tells PHPMailer to send HTML-formatted email
$mail->isHTML(true);
// The alternative email body; this is only displayed when a recipient
// opens the email in a non-HTML email client. The \r\n represents a
// line break.
$mail->AltBody = "Email Test\r\nThis email was sent through the
Amazon SES SMTP interface using the PHPMailer class.";
if(!$mail->send()) {
$emailErr = "Invalid email. Kindly double check your email and try again";
} else {
$success_message="A password reset link has been sent to your email address. Please check and reset your password";
}
/*$from = 'giasly.co.nz';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Create email headers
$headers .= 'From: '.$from."\r\n".
'Reply-To: '.$from."\r\n" .
'X-Mailer: PHP/' . phpversion();
$mail_send=mail($to,$subject,$message,$headers);
if($mail_send)
{
$success_message="A password reset link has been sent to your email address. Please check and reset your password";
}*/
#-------end-mail function----------#
}#----authentication number if end
}
else{
$emailErr = "Invalid email. Kindly double check your email and try again";
}
}
}
?>