Apache user unable to send mail via cronjob


2016-11-16 12:48:31 UTC


2017-06-22 21:01:36 UTC


Was this article helpful?

Have more questions?

Submit a request

Apache user unable to send mail via cronjob

Applicable to:

  • Plesk 12.0 for Linux


Cronjobs are not delivering mail when the script was executed as apache system user.

# sudo -u apache php /var/www/vhosts/domain.tld/mailtest.php

Mail handler 'limit-out' said: REPLY:554:5.7.0 Your message could not be sent. The sender's domain is not registered in Panel, or is misconfigured.


Script designed to run by Apache were not properly triggered.

Simple executing sudo -u apache to trigger a php script in apache user system environment is not enough. Because apache web server user does not have some special environment variables added by Apache server from vhost config like PP_VHOST_ID used by outgoing email as PPP_SENDER_VHOST_ID to identify vhost.


<IfModule mod_sysenv.c>
SetSysEnv PP_VHOST_ID "a1110b29-ec9c-47ce-84cb-0f07956de297"


Scripts should be triggered via wget or curl to run in Apache vhost environment.

# wget --quiet --spider http://domain.tld/mailtest.php


Create a sample script to use it in a cron .

sudo -u apache php /var/www/vhosts/domain.tld/sample_script.php

PP_VHOST_ID could be obtained from psa database

mysql> select name, val from domains d, dom_param dp where d.id=dp.dom_id and dp.param='vhost_id' and d.name='domain.tld';
| id | name | val |
| 250 | domain.tld | a1110b29-ec9c-47ce-84cb-0f07956de297 |
1 row in set (0.00 sec)

#sudo -u apache php /var/www/vhosts/domain.tld/sample_script.php

ini_set('display_errors', 1);


mail('user@domain.tld', 'test works', 'body');
Have more questions? Submit a request
Please sign in to leave a comment.