php - SMTP connect failed - PHPMailer Error on Localhost -


i using phpmailer latest version , able send emails using it. don't know had happened? i'm not able send mail using it. gives me following error -

mailer error: smtp connect() failed. https://github.com/phpmailer/phpmailer/wiki/troubleshooting 

i have checked openssl extension.

here code -

<form method="post" action="mail.php">    <input type="text" placeholder="enter email subscribe" name="emailid" />    <input type="submit" value="submit" />  </form>

the contents of mail.php file

<?php $emailsubscr = $_post['emailid']; $sub = 'new subscriber'; $message = $emailsubscr.' has subscribed newsletter';  require 'phpmailer/phpmailerautoload.php';  $mail = new phpmailer;  //$mail->smtpdebug = 3;  $mail->issmtp(); $mail->host = 'smtp.gmail.com';     // smtp host name $mail->smtpauth = true;                               // enable smtp authentication $mail->username = 'myusername@gmail.com';                 // smtp username $mail->password = 'mypassword';                           // smtp password $mail->smtpsecure = 'tls';                            // enable tls encryption, `ssl` accepted $mail->port = 587;                                    // tcp port connect  $mail->from = $emailsubscr; $mail->fromname = 'subscriber'; $mail->addaddress('me@example.com', 'rohit kumar');     // add recipient $mail->addreplyto($emailsubscr, 'subscriber');  $mail->subject = $sub; $mail->body    = $message;  if(!$mail->send()) {     echo 'some error occured, please try again later.';     echo 'mailer error: ' . $mail->errorinfo; } else {     echo 'thanks subscribing our newsletter on email id.'; } ?> 

thanks faiz rasool. issue resolved.

can please $mail->smtpdebug = 3; , post log   – faiz rasool

actually use mobile broadband , ip changes of time. , yesterday, google might have detected me suspicious login when tried accessing app.
when login gmail account saw notice change password due app not able login account.
you helped me. when checked debug log, there message google saying login via web browser. did so, resetted password, selected suspicious login attempt me , issue resolved.. main thing here is, after setting google's option - allow less secure apps on, google still blocking app sometimes. think reason behind (i think) ip changes when disconnect , reconnect mobile broadband. , hence, location changes. way, i'm not using gmail account anymore app.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -