Author Topic: Problem PHP Mail Function Alma Linux 8  (Read 1759 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
Problem PHP Mail Function Alma Linux 8
« on: April 20, 2024, 11:54:31 AM »
Good morning,

I am in the process of migrating the first CWP-Pro Centos 7 server to an Alma Linux 8.
Everything works perfectly (web/mail/dns/db ...) and the performance seems very good.

Only one problem that I cannot resolve :
In PHP (regardless of versions 5.xx > 8.xx) the "mail" function does not work.

There is no trace in the error logs or in recipient spam.
The tests were carried out without firewall, without antispam, without antivirus, without CBPolicyD.

Any idea to help me ?

Thanks.
Greetings.

Offline
*****
Re: Problem PHP Mail Function Alma Linux 8
« Reply #1 on: April 20, 2024, 12:16:31 PM »
mail, and mail-x are depreciated and no longer available to install.

The replacement you need to install is s-nail.

You also want to have PHP-Mail using SMTP Authentication to prevent abuse.
See: https://www.alphagnu.com/topic/43-disable-php-mail-function-in-cwp-%E2%80%93-control-webpanel/

Offline
*
Re: Problem PHP Mail Function Alma Linux 8
« Reply #2 on: April 20, 2024, 02:24:31 PM »
Thank you for this important information.

On the other hand, on this server there are a lot of php scripts that use the "mail" function.
with SMTP authentication so I have to find a way to reactivate it temporarily
to enable the transition to another solution.

Thanks for the help.

Offline
*****
Re: Problem PHP Mail Function Alma Linux 8
« Reply #3 on: April 20, 2024, 03:00:45 PM »
When you install s-nail, you still can use the mail command as it redirects automatically.

Offline
*
Re: Problem PHP Mail Function Alma Linux 8
« Reply #4 on: April 20, 2024, 03:39:28 PM »
Great,

I'm backing up the server then I'm testing by installing s-nail
in console.

Thanks.

Offline
*
Re: Problem PHP Mail Function Alma Linux 8
« Reply #5 on: April 20, 2024, 05:16:02 PM »
Test done: AlmaLinux 8 + CWP Pro
Installation of s-nail in console then reboot of the server.

The problem remains the same no mail from the php scripts and the logs
are normal without errors.

Do I need to make a special configuration or adjustment to php.ini?

Offline
*****
Re: Problem PHP Mail Function Alma Linux 8
« Reply #6 on: April 20, 2024, 11:23:05 PM »
Try to send an email from the CLI.
Just to be safe, I just tested these 3 commands from one of our mirror servers, and they worked fine.

Code: [Select]
echo "Hello world" | mail -s "Test" email_address
Code: [Select]
echo "Hello world" | mailx -s "Test" email_address
Code: [Select]
echo "Hello world" | s-nail -s "Test" email_address
e.g. - echo "Hello world" | mail -s "Test" jdoe@example.com

As you can see s-nail (Simple Sendmail) aliases mail AND mailx for backwards compatibility with scripts.

If the command line test works, then it would point more towards a script config, maybe pointing to a wrong directory.
CWP does have a different directory structure than cPanel.
But if you are going from CWP to CWP there shouldn't be any problems.

Here is something we run as a prep on all AlmaLinux 8 & 9 servers, before we even start installing CWP:
Code: [Select]
dnf install nano wget ipset ebtables iptables uuid uuid-devel libuuid-devel m4 pcre pcre-devel zlib-devel perl-DBD-MySQL perl-IPC-Cmd perl-Pod-Html perl-Sys-Hostname perl-libwww-perl.noarch perl-LWP-Protocol-https.noarch perl-GDGraph libtool s-nail htop sysstat -y

Offline
*
Re: Problem PHP Mail Function Alma Linux 8
« Reply #7 on: April 21, 2024, 08:37:14 AM »
Many thanks for your valuable help,

The server was installed with clean base AlmaLinux 8 without intervention on the files
with an update before installing CWP.

I did the tests and indeed problem:

example cmd: echo "Hello world" | s-nail -s "Test Cwp" xxxxx@domain.yyy

Result: No configuration file found at /root/.esmtprc or /etc/esmtprc

I installed another test server with AlmaLinux 8 + CWP and I get the same
issue.

Conclusion the problem seems in my opinion to come from the installation of AlmaLinux 8
on the server.

Thanks for the help.

Offline
*****
Re: Problem PHP Mail Function Alma Linux 8
« Reply #8 on: April 21, 2024, 04:59:49 PM »
That's why I tested from one of our new mirror servers, those run the bare minimum.

Are you installing AlmaLinux 8 from the DVD or minimal version? As the DVD version is recommended.
Or is this an image from a provider?

Is Postfix installed & running?

A quick Google search shows some possible solutions, like at:
https://unix.stackexchange.com/questions/711728/spam-messages-cb-crond1288-no-configuration-file-found-at-root-esmtprc-or

https://think.unblog.ch/en/send-mail-mailx-command/


Offline
*
Re: Problem PHP Mail Function Alma Linux 8
« Reply #9 on: April 22, 2024, 04:29:12 PM »
Good Morning,

Before doing new tests I reinstalled the CWP Pro Centos7 Version because
the scripts are used continuously and everything works perfectly.

I tested the Almalinux 8 64Bits image version (non-DVD) from the supplier and the original image version
of Almalinux on a cloud server and both have the same problem.

The Postfix mail server worked perfectly without problem as did all of the
CWP features.

I will install a new server to do the tests with a minimum AlmaLinux version in
version 8 because I need several versions of PHP.

Thank you for the help.

Offline
*****
Re: Problem PHP Mail Function Alma Linux 8
« Reply #10 on: April 22, 2024, 04:50:07 PM »
I can tell you , you will run into problems with the Minimal version.

Since the CLI mail test didn't work, something was missing.
Not sure if it was cronie or not.

if you run

Code: [Select]
rpm -qa | grep cron
It should show:
cronie-anacron-1.5.2-8.el8.alma.1.x86_64
cronie-1.5.2-8.el8.alma.1.x86_64
crontabs-1.11-17.20190603git.el8.noarch

The other option during testing, is install postfix, and s-nail.
If it still fails the CLI test, then some backend package required isn't being installed.

As mentioned we have the base AL8 install with CWP 8 installed on mirror servers, and those even tested OK wit the CLI test I gave you.
https://almalinux.stl.us.ssimn.org/

This is a weird problem you are having.
« Last Edit: April 22, 2024, 04:52:27 PM by Starburst »

Offline
*****
Re: Problem PHP Mail Function Alma Linux 8
« Reply #11 on: April 24, 2024, 08:37:16 AM »
Morning,

I should have asked this at the start.

Is this a virgin AlmaLinux 8 install?

Or are you using AlmaLinux-ELevate to go from CentOS 7 to AlmaLinux 8?

Offline
*
Re: Problem PHP Mail Function Alma Linux 8
« Reply #12 on: May 07, 2024, 12:09:44 PM »
Hello,

Everything works perfectly.

To resolve the problems in this post, you simply need the server OS to be in the latest stable version,
here AlmaLinux Version 8.9 (branch 8) to give CWP Pro its full exploitation without problems.

Thanks for your help Starburst,

Offline
*
Re: Problem PHP Mail Function Alma Linux 8
« Reply #13 on: October 28, 2024, 03:27:25 PM »
The same problem here.
Centos 7 stopped working at some point, installed Almalinux 8 with CWP Pro yesterday and no emails are coming from the server.

PHP(mail) is supposedly being sent but is stuck in the mail queue.
Firewall disables all ports in the router and the recipient's mail server responds with connection refused.

IP or domain is not on any blocklist

Translated with Google from Germany

Addendum:

PHP mail via Synology web server works without problems with the same domains, I briefly put the ports on the NAS to test.