mail.php work from terminal but not from web browser

Problems with the Linux version of XAMPP, questions, comments, and anything related.

mail.php work from terminal but not from web browser

Postby cefer » 26. May 2021 01:09

If in a terminal run /opt/lamp/bin/php mail.php the result is OK
but from web browser: localhost/devel/newsite/mail.php the result is FAIL
What happen here?

<?php
$to="to some mailbox in the world";
$subject="Test ONE";
$message="Testing testing";
$from = "mipc@yo.com";
$headers = "From: ".$from;

if (mail($to,$subject,$message,$headers)) {
echo "OK";
} else {
echo "FAIL";
}
?>
cefer
 
Posts: 2
Joined: 26. May 2021 00:54
XAMPP version: 7.4.10
Operating System: Manjaro

Re: mail.php work from terminal but not from web browser

Postby cefer » 26. May 2021 02:58

Searching in internet and testing later, I see what in php.ini the senmail_path need "env -i" so the line now is: sendmail_path = "env -i /usr/sbin/sendmail -t -i"
Now the result is OK, but no mail is out (from terminal yes, the mail out to the inbox)
cefer
 
Posts: 2
Joined: 26. May 2021 00:54
XAMPP version: 7.4.10
Operating System: Manjaro

Re: mail.php work from terminal but not from web browser

Postby Nobbie » 26. May 2021 10:25

In terminal your UserId from Linux is executing the process, in Apache a system user (in Xampp it is "daemon") is running the process. Probably they are not granted to the same rights for sending and receiving mails.

You might change the UserId for Apache Execution in httpd.conf (see value of USER in httpd.conf).
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 32 guests

cron