While sending email using sendmail scirpt, I was getting the error message as -
sendmail: sendmail cannot be called directly from a shell with the current user id
1. Login to WHM using root access.
2. Follow - Home >> Server Configuration >> Tweak Settings
3. Disable below two options -
i. Track email origin via X-Source email headers
ii. Prevent “nobody” from sending email
It resolved my issue. Email sent successfully.
Logs of email has been sent successfully are as follow -
2017-07-14 01:44:01 cwd=/home/cpanel_username/public_html/cgi-bin 2 args: /usr/sbin/sendmail -t
2017-07-14 01:44:01 message_id <= from_email_address U=nobody P=local S=1468 T="Application Name"
2017-07-14 01:44:01 cwd=/var/spool/exim 3 args: /usr/sbin/exim -Mc 1dVvGb-00056K-D3
2017-07-14 01:44:02 message_id3 => to_email_address <to_email_address> R=lookuphost T=remote_smtp
H=email_service_name [mail_server_ip_address] X=TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256 CV=yes C="250 2.0.0
Ok: queued as E8/6B-12306-E5778695"
2017-07-14 01:44:02 message_id Completed
Let me know your thoughts on it!