• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Issue PHP (8.1) mail() not working from command-line?

Azurel

Silver Pleskian
Server operating system version
AlmaLinux 8.6
Plesk version and microupdate number
18.0.44 Update #1
Since version 18.0.43 and possibly the ones before, I don't receive mails from PHP scripts called from the command-line anymore. I can call the same script from the browser and it works there. Has anything changed here, so that the PHP function mail() does not work anymore in command-line? There is no error. The return value of the function is TRUE in command-line and browser.

That had always worked in command-line so far. I can at least say that PHP 7.4 had worked and maybe not since the change to PHP 8.1 few weeks ago? This is a speculation, because I can not pinpoint the exact time since it no longer works. I no longer have PHP 7.4 on the server. Can anybody test it with PHP 8.1 and 7.4 on his server? :)

Replace "example.com" and mail-addy to one of yours.

# /opt/plesk/php/8.1/bin/php /var/www/vhosts/example.com/httpdocs/testmail.php

PHP:
<?php

$return = mail('[email protected]', 'TESTMAIL', 'TEXT');
var_dump($return);

?>

Does anyone have an idea or explanation for this?
 
var/log/maillog
The script is called in a cronjob and I need the results via e-mail as verification.

Execute in command-line (not working)
Jun 3 10:55:31 web1 plesk-sendmail[3526675]: S3526675: from=<[email protected]> to=<[email protected]>
Jun 3 10:55:31 web1 plesk-sendmail[3526676]: S3526675: add-from: stderr: PASS
Jun 3 10:55:31 web1 plesk-sendmail[3526676]: S3526675: check-quota: stderr: SKIP
Jun 3 10:55:31 web1 postfix/pickup[3508214]: 5B5D825A0D7F: uid=0 from=<root>
Jun 3 10:55:31 web1 postfix/cleanup[3526662]: 5B5D825A0D7F: message-id=<[email protected]>
Jun 3 10:55:31 web1 postfix/qmgr[3508215]: 5B5D825A0D7F: from=<[email protected]>, size=297, nrcpt=1 (queue active)
Jun 3 10:55:31 web1 postfix-local[3526683]: 5B5D825A0D7F: from=<[email protected]>, to=<[email protected]>, dirname=/var/qmail/mailnames
Jun 3 10:55:31 web1 dk_check[3526684]: 5B5D825A0D7F: DKIM Feed: No signature
Jun 3 10:55:31 web1 postfix-local[3526683]: 5B5D825A0D7F: dk_check: stderr: PASS
Jun 3 10:55:31 web1 dmarc[3526685]: 5B5D825A0D7F: SPF record was not found in Authentication-Results
Jun 3 10:55:31 web1 dmarc[3526685]: 5B5D825A0D7F: DMARC: smtpdomain=mail.PLESKDOMAIN maildomain=web1.PLESKDOMAIN mailfrom=[email protected] stamp=1654246531 ip=unknown adkim=relaxed aspf=relaxed p=REJECT sp=UNSPECIFIED pct=100 align_dkim=fail align_spf=fail spfres=unknown dkimres=unknown dmarccheck=DMARC_POLICY_REJECT dmarcstatus=STOP
Jun 3 10:55:31 web1 postfix-local[3526683]: 5B5D825A0D7F: dmarc: stderr: STOP
Jun 3 10:55:31 web1 postfix-local[3526683]: message discarded by a mail handler

Jun 3 10:55:31 web1 postfix/pipe[3526664]: 5B5D825A0D7F: to=<[email protected]>, relay=plesk_virtual, delay=0.03, delays=0/0/0/0.03, dsn=2.0.0, status=sent (delivered via plesk_virtual service)
Jun 3 10:55:31 web1 postfix/qmgr[3508215]: 5B5D825A0D7F: removed

Execute from browser (working)
Jun 3 11:01:04 web1 plesk-sendmail[3527524]: S3527524: from=<[email protected]> to=<[email protected]>
Jun 3 11:01:04 web1 plesk-sendmail[3527525]: S3527524: add-from: stderr: PASS
Jun 3 11:01:04 web1 plesk-sendmail[3527525]: S3527524: check-quota: stderr: SKIP
Jun 3 11:01:04 web1 plesk-sendmail[3527528]: S3527524: dk_sign: stderr: PASS
Jun 3 11:01:04 web1 postfix/pickup[3508214]: 92B4425A0C6F: uid=10007 from=<[email protected]>
Jun 3 11:01:04 web1 postfix/cleanup[3526662]: 92B4425A0C6F: message-id=<[email protected]>
Jun 3 11:01:04 web1 postfix/qmgr[3508215]: 92B4425A0C6F: from=<[email protected]>, size=658, nrcpt=1 (queue active)
Jun 3 11:01:04 web1 postfix-local[3527533]: 92B4425A0C6F: from=<[email protected]>, to=<[email protected]>, dirname=/var/qmail/mailnames
Jun 3 11:01:04 web1 postfix-local[3527533]: 92B4425A0C6F: dk_check: stderr: PASS
Jun 3 11:01:04 web1 dmarc[3527535]: 92B4425A0C6F: SPF record was not found in Authentication-Results
Jun 3 11:01:04 web1 postfix-local[3527533]: 92B4425A0C6F: dmarc: stderr: PASS
Jun 3 11:01:04 web1 dovecot[3527537]: service=lda, user=[email protected], ip=[]. msgid=<[email protected]>: saved mail to INBOX
Jun 3 11:01:04 web1 postfix/pipe[3527327]: 92B4425A0C6F: to=<[email protected]>, relay=plesk_virtual, delay=0.08, delays=0/0/0/0.08, dsn=2.0.0, status=sent (delivered via plesk_virtual service)
Jun 3 11:01:04 web1 postfix/qmgr[3508215]: 92B4425A0C6F: removed
 
Back
Top