0

I am trying to send mail using PHPMailer but when i try i get error like

MEssage Could not be sent. SMTP connect() failed

When i debug the code, I got following message:

CLIENT -> SERVER: EHLO 127.0.0.1
CLIENT -> SERVER: AUTH LOGIN
CLIENT -> SERVER: dGFsYWFzaDIwMTdAc29jZXQuZWR1Lmlu
CLIENT -> SERVER: c29jZXRAMTIz
SMTP ERROR: Password command failed: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbt5534-5.7.14 V4dQliEGa4GCkfkxZoZVAX296_Q1jP9UHhiGXQShhTqxshYg2snLu2nKW4UIhB3k4X6Kqt534-5.7.14 Q6rvXHk5aNrXU22BwfYC_VVWeFwr8-216IZQmLpq0AA9NXNaQGQHeW1ZJNQGrvUBs6f8HQ534-5.7.14 OLspMG5dlPjNzvsAGG6lHHJ7eVYFFv8sZEYvxaAkvJR1zHk27qNpB1Gc5Ld32Fbs1SpC2H534-5.7.14 981OqnvjQrzYQCbcwIwVrqfjoVQPk> Please log in via your web browser and534-5.7.14 then try again.534-5.7.14 Learn more at534 5.7.14 https://support.google.com/mail/answer/78754 n79sm9364629pfj.31 - gsmtp
SMTP Error: Could not authenticate.
CLIENT -> SERVER: QUIT
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Below is the code which i have tried:

require '../phpmailer/PHPMailerAutoload.php';
            $mail = new PHPMailer;

            //$mail->SMTPDebug = 3;                               // Enable verbose debug output
            $mail->isSMTP();
            $mail->SMTPDebug = 1;
            $mail->Debugoutput = 'html';
            $mail->Host = 'smtp.gmail.com';
            $mail->Port = 465;
            $mail->SMTPSecure = 'ssl';
            $mail->SMTPAuth = true;
            $mail->Username = 'mymail@gmail.com';                 // SMTP username
            $mail->Password = 'mypass';

            $mail->setFrom('mymail@gmail.com', 'Mailer');
            $mail->addAddress($user_email, $user_name);
            $mail->Subject = 'Registration acknowledgment GTU Techfest Zone - 1';
            $mail->Body    = '<b>You have registerd for following events:</b>'."\r\n";

            if(!$mail->send()) 
            {
                echo 'Message could not be sent.';
                echo 'Mailer Error: ' . $mail->ErrorInfo;
            } else {
                echo 'Message has been sent';
            }
            }
            else
            {
                echo "unsuccessfull".mysql_error();
            }

I have tried several solutions but its not working. I am working on localhost.I have also changed my xampp settings to send mail

  • Possible duplicate of [SMTP Connect() failed. Message was not sent.Mailer error: SMTP Connect() failed](http://stackoverflow.com/questions/18496650/smtp-connect-failed-message-was-not-sent-mailer-error-smtp-connect-failed) – Synchro Jan 16 '17 at 13:05
  • Search before you post – Synchro Jan 16 '17 at 13:06

0 Answers0