Я хочу отправить письмо по почте Yahoo, используя PHPMAILER, но это дает мне ошибку SMTP: - PullRequest
0 голосов
/ 28 октября 2019

Я хочу отправить письмо по почте Yahoo, используя PHPMAILER, но это дает мне ошибку SMTP:


    <?php
         use PHPMailer\PHPMailer\PHPMailer;
         use PHPMailer\PHPMailer\Exception;

             if(isset($_POST['btn_send'])){
               $subject = $_POST['subject'];
               $caption = $_POST['caption'];
               $senderemail = $_POST['sendingemail'];
               $senderpassword = $_POST['sending_email_pass'];
               $receiveremail = $_POST['receiver_email'];
                // Load Composer's autoloader
                require 'vendor/autoload.php';

                // Instantiation and passing `true` enables exceptions
                $mail = new PHPMailer(true);


                    //Server settings
                    $mail->SMTPDebug = 2;                 // Enable verbose debug output

                    $mail->isSMTP();
                    //$mail->CharSet = 'UTF-8';                                                                
                    // Set mailer to use SMTP
                    $mail->SMTPAuth  = true;
                    $mail->SMTPSecure = 'tls';
                    $mail->Host       = "smtp.mail.yahoo.com";  // Specify main and backup SMTP servers
                    $mail->Port       = 587;                                   // Enable SMTP authentication

                    $mail->Username   =  $senderemail;                     // SMTP username
                    $mail->Password   =  $senderpassword;                               // SMTP password
                                                  // Enable TLS encryption, `ssl` also accepted
                                                        // TCP port to connect to
                    $mail->SMTPOptions = array(
                        'ssl' => array(
                            'verify_peer' => false,
                            'verify_peer_name' => false,
                            'allow_self_signed' => true
                        )
                    );
                    //Recipients
                    $mail->setFrom($senderemail , $subject);
                    $mail->addAddress ($receiveremail);     // Add a recipient
                    //$mail->addAddress('ellen@example.com');               // Name is optional
                    //$mail->addReplyTo('info@example.com', 'Information');
                    //$mail->addCC('cc@example.com');
                    //$mail->addBCC('bcc@example.com');

                    // Attachments
                    //$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
                    //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name

                    // Content
                    $mail->isHTML(true);                                  // Set email format to HTML
                    $mail->Subject = $subject;
                    $mail->Body    = $caption;
                    //$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';



                    if($mail->send())
                    {
                        echo json_encode(['status' => 'success']);
                    }


                    }

                   // Import PHPMailer classes into the global namespace
                   // These must be at the top of your script, not inside a function




        ?>
2019-10-28 10:33:31 SERVER -> CLIENT: 220 smtp.mail.yahoo.com ESMTP ready
2019-10-28 10:33:31 CLIENT -> SERVER: EHLO localhost
2019-10-28 10:33:31 SERVER -> CLIENT: 250-smtp409.mail.ne1.yahoo.com Hello localhost [182.182.109.155])250-PIPELINING250-ENHANCEDSTATUSCODES250-8BITMIME250-SIZE 41697280250 STARTTLS
2019-10-28 10:33:31 CLIENT -> SERVER: STARTTLS
2019-10-28 10:33:31 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
2019-10-28 10:33:32 CLIENT -> SERVER: EHLO localhost
2019-10-28 10:33:32 SERVER -> CLIENT: 250-smtp409.mail.ne1.yahoo.com Hello localhost [182.182.109.155])250-PIPELINING250-ENHANCEDSTATUSCODES250-8BITMIME250-SIZE 41697280250 AUTH PLAIN LOGIN XOAUTH2 OAUTHBEARER
2019-10-28 10:33:32 CLIENT -> SERVER: AUTH LOGIN
2019-10-28 10:33:32 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2019-10-28 10:33:32 CLIENT -> SERVER: <credentials hidden>
2019-10-28 10:33:33 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2019-10-28 10:33:33 CLIENT -> SERVER: <credentials hidden>
2019-10-28 10:33:33 SERVER -> CLIENT: 535 5.7.0 (#AUTH005) Too many bad auth attempts.
2019-10-28 10:33:33 SMTP ERROR: Password command failed: 535 5.7.0 (#AUTH005) Too many bad auth attempts.
SMTP Error: Could not authenticate.
2019-10-28 10:33:33 CLIENT -> SERVER: QUIT
2019-10-28 10:33:33 SERVER -> CLIENT:
2019-10-28 10:33:33 SMTP ERROR: QUIT command failed:
SMTP Error: Could not authenticate.

Fatal error: Uncaught PHPMailer\PHPMailer\Exception: SMTP Error: Could not authenticate. in D:\xampp\htdocs\Social\Social-Platform\Social_Platform\vendor\phpmailer\phpmailer\src\PHPMailer.php:2033 Stack trace: #0 D:\xampp\htdocs\Social\Social-Platform\Social_Platform\vendor\phpmailer\phpmailer\src\PHPMailer.php(1847): PHPMailer\PHPMailer\PHPMailer->smtpConnect(Array) #1 D:\xampp\htdocs\Social\Social-Platform\Social_Platform\vendor\phpmailer\phpmailer\src\PHPMailer.php(1589): PHPMailer\PHPMailer\PHPMailer->smtpSend('Date: Mon, 28 O...', 'hello\r\n') #2 D:\xampp\htdocs\Social\Social-Platform\Social_Platform\vendor\phpmailer\phpmailer\src\PHPMailer.php(1423): PHPMailer\PHPMailer\PHPMailer->postSend() #3 D:\xampp\htdocs\Social\Social-Platform\Social_Platform\send_email.php(61): PHPMailer\PHPMailer\PHPMailer->send() #4 {main} thrown in D:\xampp\htdocs\Social\Social-Platform\Social_Platform\vendor\phpmailer\phpmailer\src\PHPMailer.php on line 2033
...