-bash: sendmail: command not found

Hello Experts,

I have been trying to send a test mail in our linux server with sendmail command.But I am getting command not found error message.

-->when I tried whether sendmail installed or not with the command

 ``` rpm -qa sendmail* ```  I got the below,
sendmail-cf-8.14.4-8.el6.noarch
sendmail-8.14.4-8.el6.x86_64

--> I can able to see sendmail.mc and sendmail.cf files under /etc/mail directory

Can anyone suggest why I am getting this command not found error message??

Server details: RHEL 6.5

Is sendmail found in the $PATH? What's the output of

whereis sendmail

?

Is sendmail alias'd? Try typing "alias sendmail" and see if you get anything.

yeah I tried,

-> "which sendmail" got below

/usr/bin/which: no sendmail in (/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/home/hyperion/bin)

->"where is sendmail" got command not found

->"alias sendmail" got command not found

Hi,

Hmm, that's odd. Anyway, try a full path of /usr/sbin/sendmail maybe ? That's where it's most likely to be found.

Also: were you typing whereis as one word (which would be correct, and as per RudiC's post) or were you typing it as two words (which wouldn't have worked) ?

Anyway, see how you get on with that path (which should be correct for RHEL/CentOS 6 x86_64, which is what I'm guessing you're using from that rpm output).

yes this time tried with "whereis sendmail" got below output

sendmail: /usr/sbin/sendmail.postfix /usr/sbin/sendmail.sendmail /usr/sbin/sendmail /usr/lib/sendmail.postfix /usr/lib/sendmail.sendmail /usr/lib/sendmail /usr/share/man/man8/sendmail.8.gz

OK...so did you try /usr/sbin/sendmail ?

when I cd to the path /usr/sbin/ I have got the below

sendmail -> /etc/alternatives/mta

Hi,

That's fine, don't worry about any of that. In your script, instead of just putting sendmail , put /usr/sbin/sendmail instead, and see if it works.

when I cd to the path /usr/sbin/ I got

sendmail -> /etc/alternatives/mta is this a file??

---------- Post updated at 10:26 AM ---------- Previous update was at 10:25 AM ----------

Oh okay I will try again

Hi,

It's a symbolic link - not a file itself, but a pointer to somewhere else. Entirely normal, and the way that Red Hat do things as part of their alternatives system.

Now, please just try typing /usr/sbin/sendmail in your command or script or whatever it is you're doing. You should find it works, where typing sendmail on its own doesn't. This is because /usr/sbin (the directory in which this link lives) is not in your path, as you saw previously.

I tried now.

[hyperion@vdcalq04108 /]$ usr/sbin/sendmail -s "test" devipriya.challa@ge.com
WARNING: RunAsUser for MSP ignored, check group ids (egid=10, want=51)
can not chdir(/var/spool/clientmqueue/): Permission denied
Program mode requires special privileges, e.g., root or TrustedUser.
[hyperion@vdcalq04108 /]$

Hi,

I'm starting to get the feeling there's some very unusual things about the way your system is set up. Is it a full, complete and otherwise normal install of Red Hat Enterprise Linux 6 or one of its derivatives (e.g. CentOS, Scientific Linux, etc) ? If this has been installed in a non-standard way or otherwise customised heavily, or if you're running in a chroot'd environment or some other kind of cut-down system, it would be handy to know that.

In any case, this error points to a potential permissions problem with the Sendmail binary itself, which shouldn't really happen in a normal out-of-the-box Red Hat system. Could you let us know what you get as the output of ls -l /usr/sbin/sendmail.sendmail , please ?

server is Liniux RHEL 6.5 version. this is new server which I am trying to send email. And I am running this with a functional ID.

I tried the command which you suggested got

[hyperion@vdcalq04108 mail]$ ls -l /usr/sbin/sendmail.sendmail
-rwxr-sr-x. 1 root smmsp 833512 Jun 17  2010 /usr/sbin/sendmail.sendmail

Hi,

Hmm, OK - that looks like I'd expect it to. Normally errors like that appear if the SETGID bit isn't properly set on the binary (the 's' in the r-s group permissions), but it appears to be.

Does your Sendmail log shed any light on this ? On RHEL this would normally be /var/log/maillog . You could also take a look at the other logs in /var/log while you're at it, in case something there sheds light on why this isn't working.

Also - is SELinux enabled on this system ? If it is, do you need it to be ?

---------- Post updated at 04:55 PM ---------- Previous update was at 04:49 PM ----------

Hi,

Also, another follow-up: I've just really realised you're running this as a regular user, sorry. If you try using the mail command instead, does it work ? So something like this:

/bin/mail -s "test" address@domain.com

You might also try postfix.

Postfix

Now I am able to send an email using sendmail. But adding attachment failed.

I am trying the below command

echo "Attachment" | /usr/lib/sendmail -v devipriya.challa@ge.com -a home/test/te.txt

but unable to get the attachment in mail.

can u please suggest!!

AFAIK sendmail doesn't offer the -a option. Don't you get an errror message? What does tne man page tell you about the options available?

Have you tried using Perl to send the email?

Email::Stuffer

I didn't get any error message while running the command. But I am getting blank email. can anyone tell the attachment parameter for sendmail command.I tried but "a" parameter won't work I guess.