Phpmailer not sending emails,and giving error

My website URL is:

http://hkmail.occasional.ml/phpmail/result.php

What I’m seeing is:

I used PHP Mailer using SMTP, where The code is

<?php

    date_default_timezone_set('Etc/UTC');

    // Edit this path if PHPMailer is in a different location.
    require 'PHPMailerAutoload.php' ;

        $mail = new PHPMailer;
       $mail->isSMTP();

        /*
        * Server Configuration
        */

        $mail->Host = 'smtp.gmail.com'; // Which SMTP server to use.
        $mail->Port = 587; // Which port to use, 587 is the default port for TLS security.
        $mail->SMTPSecure = 'tls'; // Which security method to use. TLS is most secure.
        $mail->SMTPAuth = true; // Whether you need to login. This is almost always required.
        $mail->Username = "[email protected]"; // Your Gmail address.
        $mail->Password = "password"; // Your Gmail login password or App Specific Password.

        /*
        * Message Configuration
        */

        $mail->setFrom('[email protected]', 'Awesome Website'); // Set the sender of the message.
        $mail->addAddress('[email protected]', 'John Doe'); // Set the recipient of the message.
        $mail->Subject = 'PHPMailer GMail SMTP test'; // The subject of the message.

        /*
        * Message Content - Choose simple text or HTML email
        */
        
        // Choose to send either a simple text email...
        $mail->Body = 'This is a plain-text message body'; // Set a plain text body.

        // ... or send an email with HTML.
        //$mail->msgHTML(file_get_contents('contents.html'));
        // Optional when using HTML: Set an alternative plain text message for email clients who prefer that.
        //$mail->AltBody = 'This is a plain-text message body'; 

        // Optional: attach a file
        $mail->addAttachment('images/phpmailer_mini.png');

        if ($mail->send()) {
            $result= "Your message was sent successfully!";
        } else {
             $result="Mailer Error: " . $mail->ErrorInfo;
        }


?>

Gmail not sent. and error shown was

SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub

I’m using this software:
i am using PHPmailer using SMTP.

Enable “Less Secure Apps” on the Google account settings, disable the CAPTCHA request on login, change “[email protected]” with your Gmail ID and “password” with the Gmail password and connect with port 465 and SMTP security method to ssl to the smtp.gmail.com server.

Thanking you, But it still showing same error.Even when, I did same as you told me. Please help me.

Thanking you so much, it’s work now. i unlock captcha and it works well.

Interesting, this error message looks very similar to the one from this topic.

This looks like it could be some kind of networking issue on our end. I’m going to poke around and see what I can find.

EDIT: I just tested this on your account and the message seems to send successfully. Do you still see any errors?

A post was merged into an existing topic: Yandex SMTP Email Sending Issues

A post was merged into an existing topic: Yandex SMTP Email Sending Issues

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.