• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

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('info@example.com', '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=<root@web1.PLESKDOMAIN> to=<info@example.com>
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=<20220603085531.5B5D825A0D7F@mail.PLESKDOMAIN>
Jun 3 10:55:31 web1 postfix/qmgr[3508215]: 5B5D825A0D7F: from=<root@mail.PLESKDOMAIN>, size=297, nrcpt=1 (queue active)
Jun 3 10:55:31 web1 postfix-local[3526683]: 5B5D825A0D7F: from=<root@mail.PLESKDOMAIN>, to=<info@example.com>, 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=root@web1.PLESKDOMAIN 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=<info@example.com>, 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=<domain@domain.com> to=<info@example.com>
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=<domain@domain.com>
Jun 3 11:01:04 web1 postfix/cleanup[3526662]: 92B4425A0C6F: message-id=<20220603090104.92B4425A0C6F@mail.PLESKDOMAIN>
Jun 3 11:01:04 web1 postfix/qmgr[3508215]: 92B4425A0C6F: from=<domain@domain.com>, size=658, nrcpt=1 (queue active)
Jun 3 11:01:04 web1 postfix-local[3527533]: 92B4425A0C6F: from=<domain@domain.com>, to=<info@example.com>, 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=info@example.com, ip=[]. msgid=<20220603090104.92B4425A0C6F@mail.PLESKDOMAIN>: saved mail to INBOX
Jun 3 11:01:04 web1 postfix/pipe[3527327]: 92B4425A0C6F: to=<info@example.com>, 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