mailx command working but not mail

Posted on 2005-05-04
Last Modified: 2013-12-27
I have configured sendmail on my Solaris server and the following works fine

mailx -s "Hello World" < message.txt

but the following does not work i.e I do not receive the message

cat message.txt | mail

If I look in the log file it says that the mail has been accepted by my smtp
host but I never receive it

Any ideas?.
Question by:daveyu
    LVL 9

    Expert Comment

    Try this...

    cat message.txt > mail
    LVL 40

    Expert Comment

    What does the log file show for that transaction?
    LVL 48

    Expert Comment


    I assume you made some typos with your suggestion.  Not much point in copying message.txt to mail and getting a syntax error.


    Run mail and mailx with the -v flag.  This gives you verbose output and may help you see where it is failing.

    BTW, what happens if you do

    mail <message.txt

    LVL 10

    Expert Comment

    The command

    cat message.txt | mail

    should work if your is correct.

    If you have an internal mailserver then it might be the easiest to define this as a smarthost. Go to your (in /etc or in /etc/mail) and edit the line that starts in DS to point to your mailhost, i.e. like this:

    Author Comment

    I tried mail -v, it gives Illegal option error.

    I have our external mail server set as a "smart host" in

    I tried mail < message.txt, I did not receive the email
    but the log file looks okay (to me), here it is:

    14060 >>> 220 ESMTP Sendmail 8.13.4/8.13.4; Thu, 5 May 2005 12:11:21 +0100 (BST)
    14060 <<< EHLO
    14060 >>> Hello localhost [], pleased to meet you
    14060 >>> 250-PIPELINING
    14060 >>> 250-EXPN
    14060 >>> 250-VERB
    14060 >>> 250-8BITMIME
    14060 >>> 250-SIZE
    14060 >>> 250-DSN
    14060 >>> 250-ETRN
    14060 >>> 250-DELIVERBY
    14060 >>> 250 HELP
    14060 <<< MAIL From:<> SIZE=105
    14060 >>> 250 2.1.0 <>... Sender ok
    14060 <<< RCPT To:<>
    14060 >>> 250 2.1.5 <>... Recipient ok
    14060 <<< DATA
    14060 >>> 354 Enter mail, end with "." on a line by itself
    14060 <<< Received: (from root@localhost)
    14060 <<<       by (8.13.4/8.13.4/Submit) id j45BBLax014059
    14060 <<<       for; Thu, 5 May 2005 12:11:21 +0100 (BST)
    14060 <<< Date: Thu, 5 May 2005 12:11:21 +0100 (BST)
    14060 <<< From: Super-User <>
    14060 <<< Message-Id: <>
    14060 <<< Content-Type: text
    14060 <<<
    14060 <<< Hello From ghg_adds via mail
    14060 <<<
    14060 <<< .
    14060 >>> 250 2.0.0 j45BBLOw014060 Message accepted for delivery
    14060 <<< QUIT
    14060 >>> 221 2.0.0 closing connection
    14062 === CONNECT
    14062 <<< 220 SMTP; Thu, 05 May 2005 12:05:46 +0100
    14062 >>> EHLO
    14062 <<< 250 Hello
    14062 >>> MAIL From:<>
    14062 <<< 250 <>... Sender ok
    14062 >>> RCPT To:<>
    14062 <<< 250 <>... Recipient ok
    14062 >>> DATA
    14062 <<< 354 Enter mail, end with "." on a line by itself
    14062 >>> Received: from (localhost [])
    14062 >>>       by (8.13.4/8.13.4) with ESMTP id j45BBLOw014060
    14062 >>>       for <>; Thu, 5 May 2005 12:11:21 +0100 (BST)
    14062 >>> Received: (from root@localhost)
    14062 >>>       by (8.13.4/8.13.4/Submit) id j45BBLax014059
    14062 >>>       for; Thu, 5 May 2005 12:11:21 +0100 (BST)
    14062 >>> Date: Thu, 5 May 2005 12:11:21 +0100 (BST)
    14062 >>> From: Super-User <>
    14062 >>> Message-Id: <>
    14062 >>> Content-Type: text
    14062 >>>
    14062 >>> Hello From ghg_adds via mail
    14062 >>>
    14062 >>> .
    14062 <<< 250 M2005050512054603464 Message accepted for delivery
    14062 >>> QUIT
    14062 <<< 221 closing connection.

    netserver2 is our external mail server, could this email be rejected by them?.

    LVL 40

    Accepted Solution

    According to that trace the message was delivered to and accepted by netserver2. So if you never saw the email it isn't a problem on this system but rather one on netserver2. So that's where you need to be looking.
    LVL 10

    Expert Comment

    I agree with jlevie in tht it was delivered and the problem must be searched somewhere else. It could be that some spam/antivirus-filter is classifying your mail as spam/virus because it has a source address in your own domain but is not being sent with authentication. It wouldd however not make sense that you receive the mail through mailx then.

    Just to make sure we are not searching at the wrong place: Am I correct that

    cat message.txt | mailx

    works, but

    cat message.txt | mail

    does not work (when trying with the same message.txt and the same email address ?
    LVL 48

    Expert Comment

    Just a thought.

    The first example given with mailx specified a subject line, whereas the example with mail didn't.  Perhaps there is a spam filter or similar that doesn't like email with no subject.

    Author Comment

    I shall have a look at the netsever2 end

    Yes, that is correct:-

    cat message.txt | mailx works but

    cat message.txt | mail does not work

    As for the subject I have put a line in message.txt such as:

    Subject: Hello World.

    LVL 51

    Expert Comment

    please post results of:

    ls -l `which mail`
    ls -l `which mailx`

    Author Comment

    # ls -l `which mail`
    -r-x--s--x   1 root     mail       61328 May  1  2002 /usr/bin/mail
    # ls -l `which mailx`
    -r-x--s--x   1 root     mail      126880 Oct 18  2001 /usr/bin/mailx

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Suggested Solutions

    In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
    A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now