Debian can't send mail from PHP

debian, php, phpmailer

Solution

In Ubuntu `sendmail` is not installed by default. You will have to install it manually:

sudo apt-get install sendmail-bin

EDIT 1:

In case you're using PHPMailer you can set `Sendmail` path using:

$mail->Sendmail     = '/usr/sbin/sendmail';

It's easy to test if the problem in PHP code or in your mail server configuration, or even probably firewall. Try running from the command line and see if you receive your email:

/usr/sbin/sendmail -v my@address.com < email.test

Additionally you actually could receive the mail but it could be put in SPAM folder, so check for the message there as well.

EDIT 2:

And one more thing is that you should install `sendmailconfig` and then run it to configure it:

sudo sendmailconfig

Read more about configuring `sendmail` on Ubuntu: sendmail: how to configure sendmail on ubuntu?

Problem

Mailer Error: Could not execute: /usr/sbin/sendmail I'am using debian server, the file permission is 777(all alowed), so I can't execute it why is that? ``` //Create a new PHPMailer instance $mail = new PHPMailer(); // Set PHPMailer to use the sendmail transport $mail->isSendmail(); //Set who the message is to be sent from $mail->setFrom('admin@test.com', 'test'); //Set an alternative reply-to address //$mail->addReplyTo('replyto@example.com', 'First Last'); //Set who the message is to be sent to $mail->addAddress($_POST['email'], $_POST['name']); //Set the subject line $mail->Subject = 'PHPMailer sendmail test'; //Read an HTML message body from an external file, convert referenced images to embedded, //convert HTML into a basic plain-text alternative body $mail->msgHTML("from test"); //Replace the plain text body with one created manually $mail->AltBody = 'This is a plain-text message body'; //Attach an image file //$mail->addAttachment('images/phpmailer_mini.gif'); //send the message, check for errors if (!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } ```

Original source

Related problems