Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

I’m stuck at an error sending mail to the user. I am using VPS Centos 7, and running php web using phpmailer to proceed with sending mail as below structure. It works perfectly fine when running on xampp localhost, but when I run on Centos I get Mailer error: SMTP connect() failed . I tried everything but still can’t fix it, I tried commenting the line $mail->isSMTP(true); it works, but no email is sent to the client. I also tried checking port 587, 25, and 465 to see if it listens via telnet : telnet stmp.gmail.com 587(25,465) and the result is 220. I also installed phpmailer on centos, but not sure why it won’t connect to stmp server. Hope everyone can help me with this problem.
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require_once "../vendor/autoload.php";
$mail = new PHPMailer;
$mail->isSMTP(true);
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Username = "my_email@gmail.com";
$mail->Password = "my_password";
$mail->Port = 587;
$mail->IsHTML(true);
$mail->CharSet = 'UTF-8';
$mail->From = "my_email@gmail.com";
$mail->FromName = "No Reply";
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($email_to);
if (!$mail->send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
echo 'send_mail_failed';
print_r($error);
} 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 {
$error = 'Mail error: '.$mail->ErrorInfo;
echo 'send_mail_error';
//echo $error;
}
Ken Loomis
lanbo
Azeem Cv
KFSys
doughboy
cos+digitalocean
Josep Esposito
Vivek V
Tony Rhoades
Wingrammer
gittyhubhubhub
Reaz NM