محمد مهدیزاده
1 سال پیش توسط محمد مهدیزاده مطرح شد
0 پاسخ

ارسال ایمیل با PHPMailer

من توی ارسال ایمیلم به مشکل برخورد کردم

2023-07-26 10:57:36 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP h10-20020a5d6e0a000000b003141e9e2f81sm19422232wrz.4 - gsmtp
2023-07-26 10:57:36 CLIENT -> SERVER: EHLO localhost
2023-07-26 10:57:36 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [5.126.151.127]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2023-07-26 10:57:36 CLIENT -> SERVER: STARTTLS
2023-07-26 10:57:36 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
2023-07-26 10:57:36 CLIENT -> SERVER: EHLO localhost
2023-07-26 10:57:37 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [5.126.151.127]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2023-07-26 10:57:37 CLIENT -> SERVER: AUTH LOGIN
2023-07-26 10:57:37 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2023-07-26 10:57:37 CLIENT -> SERVER: [credentials hidden]
2023-07-26 10:57:37 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2023-07-26 10:57:37 CLIENT -> SERVER: [credentials hidden]
2023-07-26 10:57:37 SERVER -> CLIENT: 535-5.7.8 Username and Password not accepted. Learn more ***** 5.7.8 https://support.google.com/mail/?p=BadCredentials h10-20020a5d6e0a000000b003141e9e2f81sm19422232wrz.4 - gsmtp
2023-07-26 10:57:37 SMTP ERROR: Password command failed: 535-5.7.8 Username and Password not accepted. Learn more ***** 5.7.8 https://support.google.com/mail/?p=BadCredentials h10-20020a5d6e0a000000b003141e9e2f81sm19422232wrz.4 - gsmtp

Fatal error: Uncaught Error: Class "PHPMailer\PHPMailer\Exception" not found in C:\xampp\htdocs\hadsook\lib\PHPMailer\src\PHPMailer.php:2212 Stack trace: #0 C:\xampp\htdocs\hadsook\lib\PHPMailer\src\PHPMailer.php(2019): PHPMailer\PHPMailer\PHPMailer->smtpConnect(Array) #1 C:\xampp\htdocs\hadsook\lib\PHPMailer\src\PHPMailer.php(1678): PHPMailer\PHPMailer\PHPMailer->smtpSend('Date: Wed, 26 J...', 'This is the HTM...') #2 C:\xampp\htdocs\hadsook\lib\PHPMailer\src\PHPMailer.php(1516): PHPMailer\PHPMailer\PHPMailer->postSend() #3 C:\xampp\htdocs\hadsook\auth\register.php(89): PHPMailer\PHPMailer\PHPMailer->send() #4 {main} thrown in C:\xampp\htdocs\hadsook\lib\PHPMailer\src\PHPMailer.php on line 2212
2023-07-26 10:57:37 CLIENT -> SERVER: QUIT
2023-07-26 10:57:37 SERVER -> CLIENT: 221 2.0.0 closing connection h10-20020a5d6e0a000000b003141e9e2f81sm19422232wrz.4 - gsmtp

این کد های ارسال ایمیله :

//Create an instance; passing `true` enables exceptions
$mail = new PHPMailer(true);

try
{
//Server settings
$mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
$mail->CharSet = "UTF-8"; //Enable verbose debug output
$mail->isSMTP(); //Send using SMTP
$mail->Host = 'smtp.gmail.com'; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = 'hadsook.gmail.com'; //SMTP username
$mail->Password = 'MYPASS'; //SMTP password
$mail->SMTPSecure = 'tls'; //Enable implicit TLS encryption
$mail->Port = 587; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`

//Recipients
$mail->setFrom('hadsook@gmail.com', 'حدسوک');
$mail->addAddress($_POST['email']);
//Content
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = '';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';

$result = $mail->send();
echo 'Message has been sent';
return $result;
}
catch (Exception $e)
{
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
return false;
}

ثبت پرسش جدید

به همدیگه کمک کنیم

به محمد مهدیزاده کمک کنید تا مشکل خودش را حل کند؛ این‌طور می‌توانیم با هم پیشرفت کنیم.

برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام