Link to home
Start Free TrialLog in
Avatar of daveyu
daveyu

asked on

mailx command working but not mail

I have configured sendmail on my Solaris server and the following works fine

mailx -s "Hello World" david@ghg.org.uk < message.txt

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

cat message.txt | mail david@ghg.org.uk

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?.
Avatar of kfullarton
kfullarton

Try this...

cat message.txt > mail david@ghg.org.uk
What does the log file show for that transaction?
Avatar of Tintin
kfullarton.

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

daveyu.

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 david@ghg.org.uk <message.txt

The command

cat message.txt | mail david@ghg.org.uk

should work if your sendmail.cf is correct.

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

DSmail.mydomain.com
Avatar of daveyu

ASKER

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

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

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

14060 >>> 220 ghg_ads.domain1.ghg.org.uk ESMTP Sendmail 8.13.4/8.13.4; Thu, 5 May 2005 12:11:21 +0100 (BST)
14060 <<< EHLO ghg_ads.domain1.ghg.org.uk
14060 >>> 250-ghg_ads.domain1.ghg.org.uk Hello localhost [127.0.0.1], pleased to meet you
14060 >>> 250-ENHANCEDSTATUSCODES
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:<root@ghg_ads.domain1.ghg.org.uk> SIZE=105
14060 >>> 250 2.1.0 <root@ghg_ads.domain1.ghg.org.uk>... Sender ok
14060 <<< RCPT To:<david.urquhart@ghg.org.uk>
14060 >>> 250 2.1.5 <david.urquhart@ghg.org.uk>... Recipient ok
14060 <<< DATA
14060 >>> 354 Enter mail, end with "." on a line by itself
14060 <<< Received: (from root@localhost)
14060 <<<       by ghg_ads.domain1.ghg.org.uk (8.13.4/8.13.4/Submit) id j45BBLax014059
14060 <<<       for david.urquhart@ghg.org.uk; Thu, 5 May 2005 12:11:21 +0100 (BST)
14060 <<< Date: Thu, 5 May 2005 12:11:21 +0100 (BST)
14060 <<< From: Super-User <root@ghg_ads.domain1.ghg.org.uk>
14060 <<< Message-Id: <200505051111.j45BBLax014059@ghg_ads.domain1.ghg.org.uk>
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 ghg_ads.domain1.ghg.org.uk closing connection
14062 === CONNECT netserver2.domain1.ghg.org.uk
14062 <<< 220 netserver2.domain1.ghg.org.uk SMTP; Thu, 05 May 2005 12:05:46 +0100
14062 >>> EHLO ghg_ads.domain1.ghg.org.uk
14062 <<< 250 netserver2.domain1.ghg.org.uk Hello
14062 >>> MAIL From:<root@ghg_ads.domain1.ghg.org.uk>
14062 <<< 250 <root@ghg_ads.domain1.ghg.org.uk>... Sender ok
14062 >>> RCPT To:<david.urquhart@ghg.org.uk>
14062 <<< 250 <david.urquhart@ghg.org.uk>... Recipient ok
14062 >>> DATA
14062 <<< 354 Enter mail, end with "." on a line by itself
14062 >>> Received: from ghg_ads.domain1.ghg.org.uk (localhost [127.0.0.1])
14062 >>>       by ghg_ads.domain1.ghg.org.uk (8.13.4/8.13.4) with ESMTP id j45BBLOw014060
14062 >>>       for <david.urquhart@ghg.org.uk>; Thu, 5 May 2005 12:11:21 +0100 (BST)
14062 >>> Received: (from root@localhost)
14062 >>>       by ghg_ads.domain1.ghg.org.uk (8.13.4/8.13.4/Submit) id j45BBLax014059
14062 >>>       for david.urquhart@ghg.org.uk; Thu, 5 May 2005 12:11:21 +0100 (BST)
14062 >>> Date: Thu, 5 May 2005 12:11:21 +0100 (BST)
14062 >>> From: Super-User <root@ghg_ads.domain1.ghg.org.uk>
14062 >>> Message-Id: <200505051111.j45BBLax014059@ghg_ads.domain1.ghg.org.uk>
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 netserver2.domain1.ghg.org.uk closing connection.
#

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





ASKER CERTIFIED SOLUTION
Avatar of jlevie
jlevie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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 david@ghg.org.uk

works, but

cat message.txt | mail david@ghg.org.uk

does not work (when trying with the same message.txt and the same email address ?
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.
Avatar of daveyu

ASKER

I shall have a look at the netsever2 end

Yes, that is correct:-

cat message.txt | mailx david@ghg.org.uk works but

cat message.txt | mail david@ghg.org.uk does not work

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

Subject: Hello World.

please post results of:

ls -l `which mail`
ls -l `which mailx`
Avatar of daveyu

ASKER

# 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
#