• 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 User Cron Script Send eMail

cmak.fr

New Pleskian
Hello

I have a system user with a scheduled task, a "Run a command" task runs a bash script.
The .sh script is run in the chrooted environment as should and works well...
... but the part where it should send an email fails.

Here is the email send command (in script):

/bin/mail -s "The subject" "[email protected]" < $msgfile

This command works fine from root ssh but doesnt from user cron.
Maybe a chroot issue.
Could any one help ?
 
It succeed to add mail but not sendmail and can not send email:

[root@host~]# ./update_chroot.sh --add mail
Done! Do not forget to run 'Work/update_chroot.sh --apply domains...' to apply changes in chroot template to domains.
[root@host ~]# ./update_chroot.sh --add sendmail
Done! Do not forget to run 'Work/update_chroot.sh --apply domains...' to apply changes in chroot template to domains.
[root@host ~]# ./update_chroot.sh --apply all
Applying chrooted environment on mydomain.org: chrootmng: skipping suid or sgid file "/var/www/vhosts/chroot/usr/sbin/sendmail"



With the system user:

bash-4.2$ type mail
mail is hashed (/usr/bin/mail)
bash-4.2$ type sendmail
bash: type: sendmail: not found
bash-4.2$ echo "Testmail" | mail -s "a try" [email protected]
/usr/sbin/sendmail: No such file or directory
"//dead.letter" 9/220
. . . message not sent.
bash-4.2$ ##same if i invoke /usr/bin/mail


Curiosity:


[root@fhost ~]#ls -la /var/www/vhosts/chroot/usr/sbin
total 1132
drwxr-xr-x 2 root root 38 Apr 14 19:39 .
drwxr-xr-x 7 root root 68 Apr 14 19:39 ..
-rwxr-xr-x 2 root root 1065376 Apr 9 19:07 ldconfig
-r-sr-xr-x 1 root root 89336 Sep 27 2018 sendmail


 
Last edited:
@Ales: i did try ssmtp. Quite same issue with guid


[root@host~]
yum install ssmtp
...
Done !

[root@host~] ./update_chroot.sh --add ssmtp
'/usr/sbin/ssmtp' -> '/var/www/vhosts/chroot/usr/sbin/ssmtp'
Done! Do not forget to run './update_chroot.sh --apply domains...' to apply changes in chroot template to domains.
[root@host~] ./update_chroot.sh --apply all
[root@host~]# ls -lah /var/www/vhosts/chroot/sbin/
total 1,2M
drwxr-xr-x 2 root root 51 20 avril 05:47 .
drwxr-xr-x 7 root root 68 14 avril 19:39 ..
-rwxr-xr-x 2 root root 1,1M 9 avril 19:07 ldconfig
-r-sr-xr-x 1 root root 88K 27 sept. 2018 sendmail
-rwxr-sr-x 1 root mail 41K 30 oct. 2014 ssmtp


With the system user:

bash-4.2$ type ssmtp
bash: type: ssmtp: not found
 
I'd remove sendmail from the chroot, change ssmtp binary's permissions and add ssmtp again.

Also, a quick search reveals this (I'm not suggesting a ssmtp recompile, just putting this here as a resource when it comes to ssmtp and chroot).
 
Back
Top