Answer the question
In order to leave comments, you need to log in
PHPmailer throws an error, what's the problem?
Good afternoon.
When connecting the PHPmailer library, the script gives an error: Parse error: syntax error, unexpected token "use" in .....site.ru/cart/zakaz.php on line 111
According to my assumption, it is related to the location of the PHPMailer file, the folder itself is located in the root folder of the site, and the handler in the folder ../cart Tell me
how can I fix this error?
111.строка use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require '../phpmailer/src/Exception.php';
require '../phpmailer/src/PHPMailer.php';
$mail = new PHPMailer(true);
$mail->CharSet = 'UTF-8';
$mail->setLanguage('ru', 'phpmailer/language/');
$mail->setFrom('[email protected]', 'Право на газ - магазин'); // от кого будет уходить письмо?
$mail->addAddress('[email protected]'); // Кому будет уходить письмо
$body = "";
$body .= "<tr><td style='padding: 10px; border: #e9e9e9 1px solid;'><b>ФИО</b></td><td style='padding: 10px; border: #e9e9e9 1px solid;'>".$surname." ".$name." ".$patronymic."</td></tr>";
$body .= "<tr><td style='padding: 10px; border: #e9e9e9 1px solid;'><b>Телефон</b></td><td style='padding: 10px; border: #e9e9e9 1px solid;'>".$phone."</td></tr>"
$message = "<head><meta charset='UTF-8'><meta http-equiv='Content-Type' content='text/html; charset=utf-8'></head> <body><table style='width: 100%;'>".$body."</table></body>";
$mail->IsHTML(true);
$mail->Subject = 'Заявка в сайта';
$mail->Body = 'Заявка №'.$_SESSION["order_id"].'<br>Итоговая сумма: '.$_SESSION['itog'].' руб.<br>' $message;
if(!$mail->send()){ false; } else { true; }
Answer the question
In order to leave comments, you need to log in
Hello.
It would be nice in this case to read the official documentation:
The use keyword must be declared in the outermost scope of a file (the global scope) or inside namespace declarations. This is because the importing is done at compile time and not runtime, so it cannot be block scoped.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question