Krydos Posted November 4, 2023 Posted November 4, 2023 4 hours ago, labbinat said: encoding the Arabic language for the data coming from the database The Arabic language coming out of the database is properly encoded, as I tested here Unless you can provide further details such as, which software you're using we might be able to help you more, but as far as I can tell the database is working perfectly. We have over 5000 users, many of which are from countries that also speak Arabic, and you're the only one claiming it doesn't work, so it makes me think it's probably your software or your settings. 4 hours ago, labbinat said: installing the PHPMAILER package to send and receive emails Here's the instructions on how to install PHPMailer https://github.com/PHPMailer/PHPMailer#installation--loading You can use Composer through Plesk, or you can just run Composer on your home PC and then upload the directory structure it creates.
labbinat Posted November 4, 2023 Author Posted November 4, 2023 Honestly, I don't know why. If you look at the previous images, you will find that only Arabic texts received from the database appear in this form: "??????????" Maybe because the server is in Latin I tested my Sabva website and hosted it on two hosting sites and did not suffer from any problems I liked dealing with you, so I am trying to solve the problem Please help me find out why
Krydos Posted November 6, 2023 Posted November 6, 2023 I did some more testing on your account and your database. How does this look? Here is the working link https://labbinat.com/krydos.php Here is the code <?php ini_set('default_charset','UTF-8'); header ('Content-Type: text/html; charset=UTF-8'); echo '<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />'; echo '<body dir="rtl">'; $db_host = "localhost"; $db_user = "labbinat_krydos"; $db_pass = "<password>"; $db_data = "labbinat_mydate"; $con = new mysqli($db_host, $db_user, $db_pass, $db_data); if ($con->connect_error) die("Connection failed: ".$con->connect_error); $con->set_charset("utf8"); $stmt = $con->prepare("select course_name from courses"); $stmt->execute(); $result = $stmt->get_result(); $stmt->close(); while ($row = $result->fetch_assoc()) { echo $row["course_name"]."<br>"; } I think the most important line that you might be missing is $con->set_charset("utf8");
labbinat Posted November 7, 2023 Author Posted November 7, 2023 Yes indeed, this line was missing and the problem was solved. Thank you from the bottom of my heart for your help There's only one problem left phpmailer
labbinat Posted November 7, 2023 Author Posted November 7, 2023 I downloaded the package to the project folder and it was working previously and this is the code that fetches it use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require 'PHPMailer/src/PHPMailer.php'; require 'PHPMailer/src/SMTP.php'; But now I am getting this error "Fatal error: Uncaught Error: Class "PHPMailer\PHPMailer\Exception" not found in /home/labbinat.com/httpdocs/PHPMailer/src/PHPMailer.php:2233 Stack trace: #0 /home/labbinat.com/httpdocs/PHPMailer/src/PHPMailer.php(2019): PHPMailer\PHPMailer\PHPMailer->smtpConnect() #1 /home/labbinat.com/httpdocs/PHPMailer/src/PHPMailer.php(1678): PHPMailer\PHPMailer\PHPMailer->smtpSend() #2 /home/labbinat.com/httpdocs/PHPMailer/src/PHPMailer.php(1516): PHPMailer\PHPMailer\PHPMailer->postSend() #3 /home/labbinat.com/httpdocs/process_registration.php(139): PHPMailer\PHPMailer\PHPMailer->send() #4 {main} thrown in /home/labbinat.com/httpdocs/PHPMailer/src/PHPMailer.php on line 2233"
Krydos Posted November 7, 2023 Posted November 7, 2023 Look at https://github.com/PHPMailer/PHPMailer#installation--loading and compare it to yours 9 hours ago, labbinat said: use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require 'PHPMailer/src/PHPMailer.php'; require 'PHPMailer/src/SMTP.php'; You're missing this line require 'path/to/PHPMailer/src/Exception.php'; So of course you get an error saying 9 hours ago, labbinat said: Class "PHPMailer\PHPMailer\Exception" not found because you didn't load the code for it.
labbinat Posted November 7, 2023 Author Posted November 7, 2023 This error appears فشل في إرسال البريد الإلكتروني: SMTP Error: Could not connect to SMTP host. Failed to connect to serverSMTP server error: Failed to connect to server SMTP code: 111 Additional SMTP info: Connection refused The strange thing is that the page and email sending were working previously. I don’t know why these errors appeared
Krydos Posted November 7, 2023 Posted November 7, 2023 What SMTP host are you trying to connect to? Host, port, etc?
labbinat Posted November 7, 2023 Author Posted November 7, 2023 $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->اسم المستخدم = '<removed>'; $mail->Password = '<removed>'; $mail->SMTPSecure = 'ssl'; $البريد->المنفذ = 465; $mail->setFrom('<removed>', 'LABBINAT'); $mail->addAddress($email); $mail->isHTML(true); $mail->CharSet = 'UTF-8';
Krydos Posted November 7, 2023 Posted November 7, 2023 (edited) Since you're trying to connect to Gmail you have to use xoauth as they recently disabled simple password authentication. Check out https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail_xoauth.phps Edited November 8, 2023 by Krydos wrong link
labbinat Posted November 7, 2023 Author Posted November 7, 2023 Sorry, I did not understand, but all the information is compatible with the main version and the error is still the same
labbinat Posted November 7, 2023 Author Posted November 7, 2023 I searched on the internet and they told me that the problem is in the firewall and certificate ssl
wolstech Posted November 7, 2023 Posted November 7, 2023 It's because the code you're using relies on "simple authentication" (a username and password), but gmail requires a standard called xoauth for scripts to send email through it. Gmail removed support for simple authentication recently. You need to either use a different email provider that still supports simple authentication (like the mail server on Johnny) or rewrite the code to implement xoauth. Here's a guide on how to use gmail with phpmailer to make a basic sending script: https://phppot.com/php/sending-email-using-phpmailer-with-gmail-xoauth2/ It's not nearly as simple but is the supported way of doing it now.
labbinat Posted November 8, 2023 Author Posted November 8, 2023 Okay, thank you for your help. You do not know how grateful I am to you
labbinat Posted November 8, 2023 Author Posted November 8, 2023 I apologize for returning again, but the application tells me that the message has been sent to the user's email, and there are no messages sent and no messages are received by the user. I searched for the reason and this was the response. “Verify that firewalls and security software on the server or device where the code is hosted are not blocking the sending process. Some security or firewalls may be blocking access to mail servers.”
Recommended Posts