S
S
SilinceW2021-05-07 07:55:16
PHP
SilinceW, 2021-05-07 07:55:16

What is the cause of the error when trying to send an email from a form (PHPMailer)?

Hello!
Please help me solve the problem:
I'm trying to set up sending emails to email from a local server (XAMPP Version: 8.0.2). Yandex SMPT is configured, previously connected another mail.php from this address without a handler, everything worked.
I hope for your help.

HTML submission form:
6094c59f2becd279875282.jpeg


js handler:
6094c5af1d8a3368354873.jpeg


mail.php file:
6094c5bd40d57194252522.jpeg


When trying to send a letter, the following errors come out:
In the console:
VM426:1 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0

"Sources" tab:
<br />
<b>Fatal error</b>:  Uncaught PHPMailer\PHPMailer\Exception: Невозможно запустить функцию mail(). in C:\xampp\htdocs\testform2\PHPMailer\src\PHPMailer.php:1904
Stack trace:
#0 C:\xampp\htdocs\testform2\PHPMailer\src\PHPMailer.php(1637): PHPMailer\PHPMailer\PHPMailer-&gt;mailSend('Date: Fri, 7 Ma...', '&lt;h1&gt;\xD0\xB2\xD0\xB0\xD0\xBC \xD0\xBF\xD1\x80...')
#1 C:\xampp\htdocs\testform2\PHPMailer\src\PHPMailer.php(1468): PHPMailer\PHPMailer\PHPMailer-&gt;postSend()
#2 C:\xampp\htdocs\testform2\mail.php(35): PHPMailer\PHPMailer\PHPMailer-&gt;send()
#3 {main}
  thrown in <b>C:\xampp\htdocs\testform2\PHPMailer\src\PHPMailer.php</b> on line <b>1904</b><br />


Screenshots of lines in phpmailer.php referenced by console

6094c97312b2e051156157.jpeg
6094c97e7a41c687362739.jpeg
6094c99046886838603972.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2021-05-07
@SilinceW

The mail() function is not allowed on the hosting or sendmail/postfix/exim is not installed.
The solution is to use sending via SMTP.
Invalid JSON is returned back to the browser - the error text comes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question