/bin/mail does nothing...

Kasyx

Expert Member
Joined
Jun 6, 2006
Messages
2,565
(Centos 4.8)

I'm trying to use /bin/mail to send me emails on completion of a script as well as some cron jobs using the following format:

Code:
*/5 * * * * cron task | mail -s "cron task" -t [email]foo@bar.derp[/email]

This is not working, i.e. it doesn't show up in /var/log/maillog. In fact, if I try this:

Code:
echo "testing" | mail -s "testing" -t [email]foo@bar.derp[/email]

It doesn't show up in /var/log/maillog either

The only way I can send mail is via /usr/sbin/sendmail:

Code:
echo "testing" | sendmail [email]foo@bar.derp[/email]

The problem with this is that sendmail does not let me specify a subject line without getting all technical with my piping, e.g.:

Code:
echo "Subject: Testing" | sendmail [email]foo@bar.derp[/email]

This obviously doesn't work when reporting on cron tasks.

Does anyone have any idea why /bin/mail is failing to do anything at all?
 
Last edited:

warwickw

Expert Member
Joined
Feb 8, 2008
Messages
1,658
or tail -f /var/log/cron and see what your cron says about your commands
 

Kasyx

Expert Member
Joined
Jun 6, 2006
Messages
2,565
why dont you try ...

tail -f /var/log/mail.err

Don't have a separate mail errlog.

or tail -f /var/log/cron and see what your cron says about your commands

It is not cron that is the problem as /bin/mail fails even when called directly from the command line.


Anyway, I've given up on /bin/mail and am instead using mutt.
 

Nod

Honorary Master
Joined
Jul 22, 2005
Messages
10,057
Is your '/bin/mail' also a link?
Code:
lrwxrwxrwx. 1 root root 5 Nov 15 11:27 /bin/mail -> mailx
Also check which package created that link for you:
Code:
rpm -qif /bin/mail

I had to remove the "-t" for the command that DeadJoe gave to work.
 
Last edited:

Kasyx

Expert Member
Joined
Jun 6, 2006
Messages
2,565
Is your '/bin/mail' also a link?
Code:
lrwxrwxrwx. 1 root root 5 Nov 15 11:27 /bin/mail -> mailx
Also check which package created that link for you:
Code:
rpm -qif /bin/mail

I had to remove the "-t" for the command that DeadJoe gave to work.

Ahh, I see that /bin/mail points to mailx, however it is not a symlink. Either way, I am using mailx directly, which works fine. No idea why calling /bin/mail doesn't work, though...

Thanks for the suggestion :D
 

Nod

Honorary Master
Joined
Jul 22, 2005
Messages
10,057
Ahh, I see that /bin/mail points to mailx, however it is not a symlink. Either way, I am using mailx directly, which works fine. No idea why calling /bin/mail doesn't work, though...

Thanks for the suggestion :D

That is weird.

If you run a md5sum on both /bin/mail and /bin/mailx, are they the same?

Do:
Code:
md5sum /bin/mailx /bin/mail|cut -d" " -f1|uniq
If you get more than one line of output, the files are not the same. As it is a hard link, it should be, but just to make sure.

You can always backup the original /bin/mail, and then soft link it to /bin/mailx.
 
Last edited:

Kasyx

Expert Member
Joined
Jun 6, 2006
Messages
2,565
That is weird.

If you run a md5sum on both /bin/mail and /bin/mailx, are they the same?

Do:
Code:
md5sum /bin/mailx /bin/mail|cut -d" " -f1|uniq
If you get more than one line of output, the files are not the same. As it is a hard link, it should be, but just to make sure.

You can always backup the original /bin/mail, and then soft link it to /bin/mailx.

MD5 checks out. The plot thickens...
 
Top