PHP Mail Error
Обратитесь за исправлением к Вашему хостинг-провайдеру, это их вина.
я обратился вот мне что прислали хотя ранее всё работало.
Пример реализации отправки со скриптов через mail():
$to = ‘support@sweb.ru, supsweb@mail.ru’;
$headers = ‘MIME-Version: 1.0’ . «\r\n» .
‘Content-type: text/html; charset=cp1251’ . «\r\n» .
‘From: ‘ . $return . «\r\n» .
‘Reply-To: ‘ . $return . «\r\n» .
‘Return-Path: ‘ . $return . «\r\n» .
‘X-Mailer: PHP/’ . phpversion();
$date = date(‘l\, M dS Y\, h:i:s A’);
mail(«$to», «mail_test», «$date», $headers);
echo «mail sent $date\n»;
Отправка почты со скриптов у вас не заблокирована, поэтому все должно решаться
Пусть хостеры пришлют лог ошибок, будет более понятно, что за косяк при отправке письма по mail()
Ранее работало на этом же хостинге? Вспомните, что делали на сайте, в коде из того, что могло привести к такому косяку?
Думаю, тут нужно включать debug в dle и смотреть там, т.к. скорей всего в лог почтового сервера это не попадёт.
DyaDya:
Пусть хостеры пришлют лог ошибок, будет более понятно, что за косяк при отправке письма по mail()
Ранее работало на этом же хостинге? Вспомните, что делали на сайте, в коде из того, что могло привести к такому косяку?
ничего такого ни делал сайты то не один а три и у всех сайтах также не работает
Php mail error что это
Настраивал сервер, все вроде встало нормально, но при попытке отправить письмо через движек DLE вылезает ошибка PHP Mail Error . Я так понял что не установлен модуль отправки писем PHP.
Нашел что ставится он командой sudo apt-get install sendmail , но при ее выполнении вылезает вот такая шляпа:
Serberg, он пишет что ненайден пакет sendmail в подключенном репозитории. Может подключенный сервер с репами недоступен? Может это временное?
У меня в ubuntu предлагает установить 6 пакетов:
procmail sendmail sendmail-base sendmail-bin sendmail-cf sensible-mda
Может тебе их скачать с какого нибудь зеркала для своего дистра, кинуть на сервер в домашнюю папку и установить вручную командой
sudo dpkg -i *.deb
How can I get the error message for the mail() function?
If the mail doesn’t send for any reason, I’d like to echo the error message. How would I do that?
8 Answers 8
If you are on Windows using SMTP, you can use error_get_last() when mail() returns false. Keep in mind this does not work with PHP’s native mail() function.
With print_r(error_get_last()) , you get something like this:
[type] => 2
[message] => mail(): Failed to connect to mailserver at "x.x.x.x" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
[file] => C:\www\X\X.php
[line] => 2
![]()
sending mail in php is not a one-step process. mail() returns true/false, but even if it returns true, it doesn’t mean the message is going to be sent. all mail() does is add the message to the queue(using sendmail or whatever you set in php.ini)
there is no reliable way to check if the message has been sent in php. you will have to look through the mail server logs.
In my case, I couldn’t get the error message in my PHP script no matter what I do ( error_get_last() , or ini_set(‘display_errors’,1); ) don’t show the error message
The return value from $mail refers only to whether or not your server’s mailing system accepted the message for delivery, and does not and can not in any way know whether or not you are providing valid arguments. For example, the return value would be false if sendmail failed to load (e.g. if it wasn’t installed properly), but would return true if sendmail loaded properly but the recipient address doesn’t exist.
I confirm this because after some failed attempts to use mail() in my PHP scripts, it turns that sendmail was not installed on my machine, however the php.ini variable sendmail_path was /usr/sbin/sendmail -t -i
1- I installed sendmail from my package manager shell> dnf install sendmail
2- I started it shell> service sendmail start
3- Now if any PHP mail() function fails I find the errors of the sendmail program logged under /var/mail/ directory. 1 file per user