Why?
I can send via mail() in PHP but I can’t send via PHPMailer using IsSendmail()
asked Dec 9, 2010 at 0:23
I’ve had the same error. Solved it by commenting/deleting this:
$mail->IsSendmail();
Now it works correctly. I can send mails, and I receive them in my inbox.
![]()
daniel__
11.6k15 gold badges64 silver badges91 bronze badges
answered Nov 8, 2012 at 0:01
nitrnitrnitrnitr
4785 silver badges13 bronze badges
1
Are you sure the path /usr/sbin/sendmail is correct?
If yes, check also the permissions for sendmail are set correctly.
answered Dec 9, 2010 at 0:33
CanerCaner
56.9k35 gold badges174 silver badges179 bronze badges
2
I had this same issue. Spent almost an hour checking logs, checking sendmail paths and testing php mail() and sendmail from command line to no avail. And finally all I did was restarted Apache using apachectl -k graceful and the universe was healed.
answered Nov 19, 2012 at 16:22
1
For me it’s working with $mail->IsSMTP().
IsSendmail() is looking for sendmail.
![]()
Tim Cooper
157k38 gold badges330 silver badges279 bronze badges
answered Feb 4, 2014 at 15:31
I agree with the bloc above. The default mail() function is enabled on all servers (i believe). In my case I was able to send basic html using the simple mail() function but when I used PHPMailer to do that I had that error.
So I removed the part where it checks i.e. IsSendMail() and all was fine. Now more exception thrown.
For people who want to use SMTP. First create an email account on your sever and then define its parameter in your code.
Cheers,
Talha
answered Jul 15, 2013 at 4:48
![]()
TalhaTalha
1,51617 silver badges15 bronze badges
Removing IsSendmail() just created another error for me, in the end the host provider had to remove safemode on the PHP settings. It then worked
Edit By David Burdess
SafeMode should not be set on a live server! For example sites that run on Joomla or other CMS solutions it should not be enabled except in a testing environment
answered Dec 23, 2013 at 13:21
AntGAntG
1,2911 gold badge19 silver badges29 bronze badges
PHP with enabled safe_mode on shared servers (and probably on others too) will fail to open /usr/sbin/sendmail (PHPMailer uses popen)
answered Sep 21, 2016 at 12:26
![]()
MisiurMisiur
4,9698 gold badges38 silver badges54 bronze badges
Why?
I can send via mail() in PHP but I can’t send via PHPMailer using IsSendmail()
asked Dec 9, 2010 at 0:23
I’ve had the same error. Solved it by commenting/deleting this:
$mail->IsSendmail();
Now it works correctly. I can send mails, and I receive them in my inbox.
![]()
daniel__
11.6k15 gold badges64 silver badges91 bronze badges
answered Nov 8, 2012 at 0:01
nitrnitrnitrnitr
4785 silver badges13 bronze badges
1
Are you sure the path /usr/sbin/sendmail is correct?
If yes, check also the permissions for sendmail are set correctly.
answered Dec 9, 2010 at 0:33
CanerCaner
56.9k35 gold badges174 silver badges179 bronze badges
2
I had this same issue. Spent almost an hour checking logs, checking sendmail paths and testing php mail() and sendmail from command line to no avail. And finally all I did was restarted Apache using apachectl -k graceful and the universe was healed.
answered Nov 19, 2012 at 16:22
1
For me it’s working with $mail->IsSMTP().
IsSendmail() is looking for sendmail.
![]()
Tim Cooper
157k38 gold badges330 silver badges279 bronze badges
answered Feb 4, 2014 at 15:31
I agree with the bloc above. The default mail() function is enabled on all servers (i believe). In my case I was able to send basic html using the simple mail() function but when I used PHPMailer to do that I had that error.
So I removed the part where it checks i.e. IsSendMail() and all was fine. Now more exception thrown.
For people who want to use SMTP. First create an email account on your sever and then define its parameter in your code.
Cheers,
Talha
answered Jul 15, 2013 at 4:48
![]()
TalhaTalha
1,51617 silver badges15 bronze badges
Removing IsSendmail() just created another error for me, in the end the host provider had to remove safemode on the PHP settings. It then worked
Edit By David Burdess
SafeMode should not be set on a live server! For example sites that run on Joomla or other CMS solutions it should not be enabled except in a testing environment
answered Dec 23, 2013 at 13:21
AntGAntG
1,2911 gold badge19 silver badges29 bronze badges
PHP with enabled safe_mode on shared servers (and probably on others too) will fail to open /usr/sbin/sendmail (PHPMailer uses popen)
answered Sep 21, 2016 at 12:26
![]()
MisiurMisiur
4,9698 gold badges38 silver badges54 bronze badges
Struggling with the ould not execute /usr/sbin/sendmail error? Our Sendmail Support team is here to help you with your questions and concerns.
Could not execute /usr/sbin/sendmail Error | Fixed
If you have been coming across the “could not execute /usr/sbin/sendmail” error message, you are in luck. Our experts have a solution to help you resolve this error in no time. In fact, this error occurs when a program or script tries to send an email via the sendmail command but fails.

According to our experts, the Sendmail command is a standard MTA or mail transfer agent that is popularly used by many Unix and Linux-based systems to send email messages.
Let’s take a look at how Sendmail works. When a program or script uses sends an email with the sendmail command, the email message is sent to the local sendmail process. This process is responsible for delivering the email to its destination.
The “could not execute /usr/sbin/sendmail” could be due to a few different reasons, such as:
- Incorrect path:
The program or script is using an incorrect path to the sendmail command. For instance, it is using /bin/sendmail instead of /usr/sbin/sendmail.
- Missing or corrupted sendmail binary:
The sendmail binary is missing or corrupted.
- Permissions issues:
The error will occur if the user does not have sufficient permissions to execute the sendmail command.
We can easily resolve this error, with the following steps:
- To begin with, verify the path to the sendmail command and ensure that it is correct.
- Verify the sendmail binary is present in the /usr/sbin directory. We have to install it if it is missing.
- Next, check the user running the program or script has the required permission to execute the sendmail command.
Let us know in the comments if you need further help with resolving the could not execute /usr/sbin/sendmail error.
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
To conclude, our Support Techs demonstrated the various causes and fixes for the could not execute /usr/sbin/sendmail error.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
GET STARTED
PHPMAILER_EXECUTE/usr/sbin/sendmail, Mailer Error: Could not execute: /usr/sbin/sendmail, notice Письмо не может быть отправлено — именно так могут заканчиваться попытки отправки E-Mail в Joomla 1.5 когда дядя хостер неправильно настроил sendmail, чмоды на доступ к нему или запретил его экзекуцию.
Если те же проблемы с отправкой электронных писем (E-Mail) через sendmail или SMTP в Joomla 1.5, то первым делом посмотрите в информации про PHP полный путь к sendmail и если в общей конфигурации он прописан верно, то в той же информации про PHP смотрите значения директивы с именем disable_functions и если оно равно = exec, system, shell_exec, passthru, popen, dl, set_time_limit, max_execution_time, ini_restore, mail, то попытки отправки электронных писем (E-Mail) именно через sendmail будут накрываться медным тазом ибо экзекуция (выполнение) sendmail происходит посредством функции popen!
Единственный выход — это пробовать отправлять почту через SMTP сервер и с общими настройками Joomla для отправки электронных писем (E-Mail) через SMTPя думаю проблем не должно возникнуть, одно единственное, что следует упомянуть, так это то, что при использовании «Отправить эту ссылку по почте» в поле Ваш E-Mail:
пользователь должен указать как раз не свой, а наш E-Mail под учётной записью которого отправляется электронная почта (E-Mail) через SMTP потому, что SMTP сервер требует совпадения имени отправителя (Ваш E-Mail, From) с именем учетной записи под которой идёт подключение к SMTPсерверу: sender address must match authenticated user SMTP.
SMTP -> FROM SERVER: 220 smtp21.mail.ru ESMTP ready SMTP -> FROM SERVER: 250-smtp21.mail.ru 250-SIZE 73400320 250-8BITMIME 250-AUTH PLAIN LOGIN 250 STARTTLS SMTP -> FROM SERVER: 250 OK SMTP -> FROM SERVER: 501 sender address must match authenticated user SMTP -> ERROR: RCPT not accepted from server: 501 sender address must match authenticated user SMTP -> FROM SERVER: 503 sender not yet given SMTP -> ERROR: RSET failed: 503 sender not yet given Mailer Error: SMTP Error: The following SMTP Error: Data not [email protected]
Для того чтобы посетители сайта могли использовать возможность «Отправить эту ссылку по почте» в условиях настройки Joomla для отправки электронной почты (E-Mail) через SMTP, то мы должны сделать соответствующее объявление на своём сайте, в котором опубликовать наш E-Mail от имени которого происходит подключение к SMTP серверуи тогда функция «Отправить эту ссылку по почте» должна будет заработать!
Отправить эту ссылку по почте
E-mail адресата: [email protected]
Ваше имя: Vasya
Ваш E-Mail: [email protected]
Тема: Ku-Ku!SMTP -> FROM SERVER: 220 smtp9.mail.ru ESMTP ready SMTP -> FROM SERVER: 250-smtp9.mail.ru 250-SIZE 73400320 250-8BITMIME 250-AUTH PLAIN LOGIN 250 STARTTLS SMTP -> FROM SERVER: 250 OK SMTP -> FROM SERVER: 250 Accepted SMTP -> FROM SERVER: 354 Enter message, ending with «.» on a line by itself SMTP -> FROM SERVER: 250 OK id=1Sz8ZZ-0002IH-Jq SMTP -> FROM SERVER: 221 smtp9.mail.ru closing connection Message sent!
В Joomla 1.5 для отправки писем используется библиотека PHPMailer v2.0.4 for PHP4, расположенная по адресу /libraries/phpmailer/phpmailer.php и если общие настройки в Joomla сделаны верно, а почта не уходит и нельза определить ошибку, то используйте приведённые ниже куски кода для тестирования PHPMailer.
Пример использования PHPMailer для отправки через sendmail:
<?php require_once('./libraries/phpmailer/phpmailer.php'); $mail = new PHPMailer(); // defaults to using php "mail()" $mail->IsSendmail(); // telling the class to use SendMail transport $mail->Sendmail = '/usr/sbin/sendmail'; // Set full path to sendmail //$body = file_get_contents('contents.html'); $body = 'body'; //$body = eregi_replace("[]",'',$body); $mail->AddReplyTo("[email protected]","First Last"); //$mail->SetFrom('[email protected]', 'First Last'); $mail->From = '[email protected]'; $mail->AddReplyTo("[email protected]","First Last"); $address = "[email protected]"; $mail->AddAddress($address, "John Doe"); $mail->Subject = "PHPMailer Test Subject via Sendmail, basic"; // optional, comment out and test $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; $mail->MsgHTML($body); //$mail->AddAttachment("images/phpmailer.gif"); // attachment //$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; }
Пример использования PHPMailer для отправки через SMTP сервер:
<?php # http://phpmailer.worxware.com/index.php?pg=examples require_once('./libraries/phpmailer/phpmailer.php'); $mail = new PHPMailer(); // defaults to using php "mail()" $mail->IsSMTP(); // telling the class to use SMTP //$body = file_get_contents('contents.html'); $body = 'body'; //$body = eregi_replace("[]",'',$body); $mail->SMTPDebug = 2; // enables SMTP debug information (for testing) $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "smtp.mail.ru"; // SMTP server $mail->Port = 25; // set the SMTP port for the GMAIL $mail->Username = "[email protected]"; // SMTP account username $mail->Password = "mainpass"; // SMTP account password $mail->AddReplyTo("[email protected]","First Last"); //$mail->SetFrom('[email protected]', 'First Last'); $mail->From = '[email protected]'; $mail->AddReplyTo("[email protected]","First Last"); $address = "[email protected]"; $mail->AddAddress($address, "John Doe"); $mail->Subject = "PHPMailer Test Subject via Sendmail, basic"; // optional, comment out and test $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; $mail->MsgHTML($body); //$mail->AddAttachment("images/phpmailer.gif"); // attachment //$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; }
В некоторых случаях, настройки некоторых модулей могут некорректно работать с SMTP настройками и выдавать PHPMAILER_RECIPIENTS_FAILED, это происходит из-за несоответствия SMTP логина с именем отправителя, по идее должен помочь следующий рецепт: открываем components/com_contact/controller.php, находим строку 194 и меняем:
Только после полного отключения блокировщика скриптов и рекламы на этом месте появится полезная подсказка/ссылка/код/пример конфигурации/etc!
Письмо не может быть отправлено из-за кривого com_mailto
Кнопка E-mail (отправить ссылку другу) служит для отправки другу или недругу ссылки на какой-то материал. Письмо не может быть отправлено через эту кнопку из-за кривого /components/com_mailto/controller.php, в котором не верно рассчитывается таймаут и проверка «Verify that this is a local link«. Открываем /components/com_mailto/controller.php, находим строки:
// we return time() instead of 0 (as it previously was), ... if($timeout == 0 || time() - $timeout < MAILTO_TIMEOUT) { JError::raiseNotice( 500, JText:: _ ('EMAIL_NOT_SENT')); return $this->mailto(); } //...... // Verify that this is a local link if((!$link) || (!JURI::isInternal($link))) { //Non-local url... JError::raiseNotice( 500, JText:: _ ('EMAIL_NOT_SENT' )); return $this->mailto(); }
И меняем их до такой кондиции:
Только после полного отключения блокировщика скриптов и рекламы на этом месте появится полезная подсказка/ссылка/код/пример конфигурации/etc!
Также будет полезно увеличить значение константы MAILTO_TIMEOUT с 20 до 50! Эта бага упоминалась на:
- 1.5.23 E-mail could not be sent.
- Joomla! • View topic — E-mail could not be sent.
Hello. I tried send an email from our server but I got this error: Could not execute: /usr/sbin/sendmail -t -i
This is my email file. I call twice the function send.
<?php /* * Email Class * Send emails. */ class Email { private $mail; public function __construct(){ require "vendor/phpmailer/phpmailer/PHPMailerAutoload.php"; $this->mail = new PHPMailer; $this->mail->isSendmail(); } public function send($to_email, $to_name, $subject, $message){ $this->mail->clearAddresses(); $this->mail->setFrom("gestao@xxxx.pt", "Name"); $this->mail->addAddress($to_email, $to_name); $this->mail->addReplyTo("xxxx@xxxxx.pt", "Name"); $this->mail->Subject = $subject; $this->mail->Body = $message; return $this->mail->send(); } public function getError(){ return $this->mail->ErrorInfo; } }
P.S.: I’m sorry for my English.
