尝试与 PHP 建立 SMTP 连接时出现错误?

时间:2021-03-13 16:10:28

标签: php email smtp phpmailer

您可以在下面看到我的 send_mail.php 文件。

    <?php
  require("PHPMailer/src/Exception.php");
  require("PHPMailer/src/PHPMailer.php");
  require("PHPMailer/src/SMTP.php");

  use PHPMailer\PHPMailer\Exception;
  use PHPMailer\PHPMailer\PHPMailer;
  use PHPMailer\PHPMailer\SMTP;
  /*
  require_once("mail/PHPMailerAutoload.php");
  */
  session_start();
  $sifre = $_SESSION["sifre"];
  /*
  echo $sifre . "<br>";
  */
  $mail = new PHPMailer();
  $mail->IsSMTP();
  $mail->SMTPDebug = 2; 
  $mail->SMTPAuth = true;
  $mail->SMTPSecure = 'tls';
  $mail->Host = 'smtp.yandex.com';
  $mail->Port = 587;
  $mail->IsHTML(true);
  $mail->SetLanguage("tr", "phpmailer/language");
  $mail->CharSet ="utf-8";
  $mail->Username = "hakantalha1@yandex.com"; 
  $mail->Password = "h123456";
  $mail->SetFrom("info@mydomain.com", "Değer Kaybı"); // Mail attigimizda yazacak isim
  $mail->AddAddress("hakantalha1@yandex.com"); // Maili gonderecegimiz kisi/ alici
  $mail->Subject = "Şifremi Unuttum"; // Konu basligi
  $mail->Body = "Şifreniz: " . $sifre; // Mailin icerigi
  if(!$mail->Send()){
    echo "Mailer Error: ".$mail->ErrorInfo;
} else {
    echo "Mesaj gonderildi";
}
?>

您可以在下方看到我收到的错误。

    2021-03-13 15:55:27 SERVER -> CLIENT: 220 vla5-445dc1c4c112.qloud-c.yandex.net ESMTP (Want to use Yandex.Mail for your domain? Visit http://pdd.yandex.ru)
2021-03-13 15:55:27 CLIENT -> SERVER: EHLO localhost
2021-03-13 15:55:27 SERVER -> CLIENT: 250-vla5-445dc1c4c112.qloud-c.yandex.net250-8BITMIME250-PIPELINING250-SIZE 42991616250-STARTTLS250-AUTH LOGIN PLAIN XOAUTH2250-DSN250 ENHANCEDSTATUSCODES
2021-03-13 15:55:27 CLIENT -> SERVER: STARTTLS
2021-03-13 15:55:27 SERVER -> CLIENT: 220 Go ahead
2021-03-13 15:55:27 CLIENT -> SERVER: EHLO localhost
2021-03-13 15:55:27 SERVER -> CLIENT: 250-vla5-445dc1c4c112.qloud-c.yandex.net250-8BITMIME250-PIPELINING250-SIZE 42991616250-AUTH LOGIN PLAIN XOAUTH2250-DSN250 ENHANCEDSTATUSCODES
2021-03-13 15:55:27 CLIENT -> SERVER: AUTH LOGIN
2021-03-13 15:55:27 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2021-03-13 15:55:27 CLIENT -> SERVER: [credentials hidden]
2021-03-13 15:55:27 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2021-03-13 15:55:27 CLIENT -> SERVER: [credentials hidden]
2021-03-13 15:55:28 SERVER -> CLIENT: 535 5.7.8 Error: authentication failed: This user does not have access rights to this service
2021-03-13 15:55:28 SMTP ERROR: Password command failed: 535 5.7.8 Error: authentication failed: This user does not have access rights to this service
SMTP Error: Could not authenticate.
2021-03-13 15:55:28 CLIENT -> SERVER: QUIT
2021-03-13 15:55:28 SERVER -> CLIENT: 221 2.0.0 Closing connection.
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

我正在尝试与 XAMPP 建立连接。我有 PHPMailer 5.5 版并编辑了 XAMPP .ini 文件。你能帮我吗,我收到错误的原因是什么?

0 个答案:

没有答案