I try this:

<?php if(!mail("куда отправляем", "я письмо", "я сообщение")) echo 'не пашет '; ?> 

I press Enter , writes не пашет . I tried on another hosting, everything works. What to do? Contact those support? Or fix something yourself?

  • Most likely, you did not raise the mail server on your host. - user26699
  • And php logs looked? Usually, either sendmail is not configured, or there is no right, or it is completely absent - BOPOH

2 answers 2

If you use the services of a regular hosting service, then this function should be supplied by the host. You need to ask a question for technical support.

If this is a VPS server, and you are administering its administration, it is better to use the services of professional administrators to set up sendmail . This is a rather complicated process. If you want to try it yourself, you should configure exim , for example. An article on customization is here .

How to check?

Go to the /var/log directory /var/log look for the mail file there, it contains errors if sendmail is configured.

I also recommend that you look in the error.log file, it usually lies in /var/log/apache/error.log . There may be some errors in this file.

If you have access to the php.ini , look at the sendmail_path parameter, perhaps its path is not correct. The path to sendmail can be viewed with the command which sendmail . An example of the correct parameters:

 sendmail_path = /usr/sbin/sendmail -t -i -F"Full Name" -f'emailaddress@example.com' 

    Addition to the answer @GrayHoax

    This is in case the hoster cannot \ does not want to provide its mail server.

    To send mail you need:

    1. Raise your smtp server
    2. Use smtp server for example google or yandex

    The script taken from the English version

     // Pear Mail Library require_once "Mail.php"; $from = '<from.gmail.com>'; $to = '<to.yahoo.com>'; $subject = 'Hi!'; $body = "Hi,\n\nHow are you?"; $headers = array( 'From' => $from, 'To' => $to, 'Subject' => $subject ); $smtp = Mail::factory('smtp', array( 'host' => 'ssl://smtp.gmail.com', 'port' => '465', 'auth' => true, 'username' => 'johndoe@gmail.com', 'password' => 'passwordxxx' )); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo('<p>' . $mail->getMessage() . '</p>'); } else { echo('<p>Message successfully sent!</p>'); }