0

I have Webuzo VPS and want to use PHPMailer library.

I did it with the below settings:

In php.ini , I have write extension=openssl.so In PHP extension, all module already set up.

and here is my code for sent email dynamically:

require '../vendor/autoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;    
$mail->Host = 'smtp.gmail.com';
$mail->Portgiven = 587;
$mail->SMTPSecure = 'tls';    
$mail->SMTPAuth = true;    
$mail->Username = "vector41line6@gmail.com";    
$mail->Password = "password";    
$mail->setFrom('vector41line6@gmail.com', 'vector 41 line6');    
$mail->addReplyTo('vector41line6@gmail.com', 'vector 41 line6');    
$mail->addAddress($email);    
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Vector 41 Recruitment';
$mail->Body = "some messages";
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';           

//send the message, check for errors
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}

It gives error: SMTP access error. What should i do?

Note. My code is working fine in XAMPP apps, so I think it's not that issue.

Error message

2019-03-04 08:02:14 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP a5sm6779032pgv.12 - gsmtp
2019-03-04 08:02:14 CLIENT -> SERVER: EHLO 192.168.88.120
2019-03-04 08:02:14 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [180.249.242.237]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2019-03-04 08:02:14 CLIENT -> SERVER: STARTTLS
2019-03-04 08:02:14 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
SMTP Error: Could not connect to SMTP host.
2019-03-04 08:02:14 CLIENT -> SERVER: QUIT
2019-03-04 08:02:14 
2019-03-04 08:02:14 
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
karel
  • 5,489
  • 46
  • 45
  • 50

1 Answers1

0

This is not a code problem; it's an environment problem. You have a certificate validation failure due to the CA certificate bundle on your live server being out of date. Your local copy is OK, which is why it's working there. Your connection is not being blocked by your ISP.

Follow the advice in the troubleshooting guide on how to update your CA bundle. In short, ensure your server's packages are up to date, and if they are, update your CA bundle yourself, or use the Certainty package to maintain your own copy.

Synchro
  • 35,538
  • 15
  • 81
  • 104