• Plesk Uservoice will be deprecated by October. Moving forward, all product feature requests and improvement suggestions will be managed through our new platform Plesk Productboard.
    To continue sharing your ideas and feedback, please visit features.plesk.com

Issue Can't send email via php mail() on alma9.x

WSNHosting

Basic Pleskian
Server operating system version
Alma 9.x
Plesk version and microupdate number
18.0.71
Hello all

i install new plesk on alma 9.x last version

i found can't send email by php script on function mail();

in php.ini

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; PHP: Runtime Configuration - Manual
;sendmail_path =



but i add php option on domain

sendmail_path = /usr/sbin/sendmail -t -i

can send email

but i no need add

sendmail_path = /usr/sbin/sendmail -t -i

all domain in php option on domain site

What's causing this?
Is there a solution?
 
You should be able to see some error when you try it either on the /var/log/maillog or on the domain logs
 
Generally you don't need to explicitly add /usr/sbin/sendmail -t -i to the sendmail_path configuration because it's the default already. See PHP documentation.

Maybe there is something in your PHP configuration that removes or overwrites the default sendmail_path value?
 
What is the output output when you run:
Bash:
grep -R "sendmail_path =" /opt/plesk/php/*
?
[root@ns1 ~]# grep -R "sendmail_path =" /opt/plesk/php/*
/opt/plesk/php/5.6/etc/php.ini:;sendmail_path =
/opt/plesk/php/7.0/etc/php.ini:;sendmail_path =
/opt/plesk/php/7.4/etc/php.ini:;sendmail_path =
/opt/plesk/php/8.0/etc/php.ini:;sendmail_path =
/opt/plesk/php/8.1/etc/php.ini:;sendmail_path =
/opt/plesk/php/8.2/etc/php.ini:;sendmail_path =
/opt/plesk/php/8.3/etc/php.ini:;sendmail_path =
/opt/plesk/php/8.4/etc/php.ini:;sendmail_path =
[root@ns1 ~]#
 
i not found error

Rejecting message: system user is not allowed to send mail

in /var/log/maillog

like https://support.plesk.com/hc/en-us/...er-The-user-user-is-not-allowed-to-send-email

In my case, this is:

When selecting PHP version 5.6 or 7.0.3, the default PHP settings for sending emails do not specify the email sending command.

But when selecting PHP from version 7.4 and above, the path for sending email will be specified.

This problem occurred when I used PHP to send a message using the command:

echo mail($to, $subject, $message, $headers)

Normally, a 1 is returned when the message is successful. However, the problem I encountered was that no message was sent, and no status was displayed indicating whether the message was successful. And no error message logs were found in php or mail logs.

If I enter the command

sendmail_path = /usr/sbin/sendmail -t -i

Adding just one domain to work.

php-7.0.3.jpgphp-8.3.jpg
 
That's odd and to be honest I am not sure what would cause this, as the output of grep -R "sendmail_path =" /opt/plesk/php/* shows that there are no other values defines for the sendmail_path parameter. Perhaps the parameter is overwritten somewhere else, maybe like an .htaccess file?

You could also try to re-install PHP 5.6 and 7.0 modules from Plesk to see if that fixes the issue.

Other than that I am afraid I am out of suggestions.
 
Looks like a PHP bug initially reported for version 5.2:
There's a second report, so it could very likely affect version 7.0:

The workaround to consider is manually adding sendmail_path = "/usr/sbin/sendmail -t -i" into /opt/plesk/php/<php_verion>/etc/php.ini or through Tools & Settings > PHP Settings > PHP 5.6 / 7.0 PHP > php.ini. I hope that helps.
 
Back
Top