By vin2164382
Hello everyone, currently my website is in need of a password recovery system by email. I’ve got the recovery site, and it’s written in php using phpmailer on xampp. It worked fine, but when I put it on VPS centos 7, it didn’t work anymore, here is my config to listen to the gmail server:
include "../vendor/autoload.php";
$mail = new PHPMailer;
$mail->isSMTP(true);
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Username = "my_email_username";
$mail->Password = "my_email_password";
$mail->Port = 587;
$mail->IsHTML(true);
$mail->CharSet = 'UTF-8';
$mail->From = "my_email";
$mail->FromName = "No Reply";
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($email_to);
if (!$mail->send()) {
echo 'send_mail_failed';
} else {
$update_password_byEmail = "UPDATE account SET password=:gen_password WHERE name=:currentUser AND email=:currentEmail;";
$stmt_gen_pass_update = $sqlWeb->prepare($update_password_byEmail);
$stmt_gen_pass_update->bindValue(':gen_password', md5($password_generate));
$stmt_gen_pass_update->bindValue(':currentUser', $usernameOfEmail);
$stmt_gen_pass_update->bindValue(':currentEmail', $target_email);
$stmt_gen_pass_update->execute();
$stmt_gen_pass_update->closeCursor();
echo 'send_mail_successful';
}
} else {
echo 'send_mail_error';
}
Anyone who has experience in installing and operating it please help me find a solution to install and use phpmailer on centos 7. I am new in this field, and am trying to improve my experience. myself. Thank you very much.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
The configuration looks correct. Do you get any specific errors?
What I could suggest is testing the connection to the Google SMTP service on port 587 with telnet:
telnet smtp.gmail.com 587
Let me know how it goes. Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.