Problems sending mail: Difference between Mail and Mailx?


 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Problems sending mail: Difference between Mail and Mailx?
# 1  
Old 09-04-2013
Problems sending mail: Difference between Mail and Mailx?

Whats the difference between mail and mailx?

I'm trying to troubleshoot a problem where I can send mail from server A with this
Code:
`echo $MESSAGE | mail -s "$SUBJECT" -r $FROM $RECIPIENTS`

command but executing the same command from server B throws me this error (Both servers are RHEL)

Code:
    mail: invalid option -- r
    Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
                [-- sendmail-options ...]
           mail [-iInNv] -f [name]
           mail [-iInNv] [-u user]

Now... going through mail manpages to ty to understand whats happening, `man mail` gives me this:

In Server A

Code:
    MAILX(1)                         User Commands                        MAILX(1)
    
    NAME
           mailx - send and receive Internet mail
    
    SYNOPSIS
           mailx [-BDdEFintv~] [-s subject] [-a attachment ] [-c cc-addr] [-b bcc-addr] [-r from-addr] [-h hops]
                  [-A account] [-S variable[=value]] to-addr . . .
           mailx [-BDdeEHiInNRv~] [-T name] [-A account] [-S variable[=value]] -f [name]
           mailx [-BDdeEinNRv~] [-A account] [-S variable[=value]] [-u user]


But in server B

Code:
    MAIL(1)                   BSD General Commands Manual                  MAIL(1)
    
    NAME
         mail - send and receive mail
    
    SYNOPSIS
         mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr... [-- sendmail-options...]
         mail [-iInNv] -f [name]
         mail [-iInNv] [-u user]

Now... if I try `man mailx` in server B I get:

Code:
  MAILX(P)                   POSIX Programmerâs Manual                  MAILX(P)
    
    PROLOG
           This manual page is part of the POSIX Programmerâs Manual.  The Linux implementation of this interface may differ
           (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not  be  imple-
           mented on Linux.
    
    NAME
           mailx - process messages
    
    SYNOPSIS
       Send Mode
                  mailx [-s subject] address...
    
       Receive Mode
                  mailx -e
    
                  mailx [-HiNn][-F][-u user]
    
                  mailx -f[-HiNn][-F][file]

Server B has a different version of mail than Server A? Mailx and Mail are different things? I would like to use the -r option I use in server A but in server B and I don't really know whats happening.
# 2  
Old 09-04-2013
The -r option is not portable. Maybe on purpose because it's ideal for a spammer.
The default is the user who sends the mail, and the administrator put some rules to generate a sender address out of it. (And that's not safe against a professional spammer either.)
I like the old Unix mail or sendmail tools that do not even know a -s option, and you have to construct the mail header in SMTP style:
Code:
echo "\
Subject: $SUBJECT 
From: $FROM

$MESSAGE
" | mail $RECIPIENTS

NB an empty line indicates the end of the header section.
You can still try that with your advanced mail and mailx programs...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Mailx working but not sending mail

Hi All, I have a unix server on which mailx is configured . Earlier i was getting proper mails but now some mails are getting stuck and i am not receiving the emails from the server. I can see the mails in mailq. Can you please help me with this . How can i receive these emails? (2 Replies)
Discussion started by: pratikm23
2 Replies

2. Shell Programming and Scripting

mailx -s not sending the file to mail address

Hi All, OS:Red Hat Linux 4 86x64 Below is my shell script which is not sending mail to the mail recipient: #!/bin/bash export MAILLIST="xyz@yahoo.com" cd <path_to_the_script_perf_report.sql> sqlplus / as sysdba @perf_report.sql if then cat <path_to_the_script/*MONTHLY*REPORT*.lst... (6 Replies)
Discussion started by: a1_win
6 Replies

3. Shell Programming and Scripting

sending mail through mailx command

Hi I need help to send mail through mailx command . Currenlt my program is like #!/bin/ksh -x echo " " >> path.lst MAIL_LIST='someone1@gamil.com someone2@gamil.com someone3@gamil.com' cat path.lst | mailx -s "path loaction" $MAIL_LIST echo "End" exit 0 Its work fine . But i... (3 Replies)
Discussion started by: mani_isha
3 Replies

4. Shell Programming and Scripting

sending mail using Mailx with data from oracle table

Hi, i need to send emails to the mail ids i receive using the sql query . SELECT L.ALARM_DEF,L.CRITERIA,L.DISTANCE_METRE,L.EMAIL,L.LAC_ID,L.LAST_CHECK,L.RANGE, L.RESOURCE_MSISDN,LM.ADDRESS,LM.NAME FROM LANDMARK_ALARM_CONF l, LANDMARK lm WHERE L.LANDMARK_ID=LM.LANDMARK_ID AND... (0 Replies)
Discussion started by: aemunathan
0 Replies

5. UNIX for Advanced & Expert Users

Sendmail problems -- with sending mail

Hello, I am C. and I would like to send mail with Sendmail to my hotmail-account. But this doesn't work, the mail always returns in the file: /var/spool/mail/root. Probably there is something wrong with my SmartHost. I configured it like: define ( 'SMART_HOST','smtp.direct-adsl.be') -->... (1 Reply)
Discussion started by: caroline
1 Replies

6. Shell Programming and Scripting

sending mail from perl using mailx

hi All, i am trying to send a mail from perl using mailx. the script runs fine if i hard code the file path which is to be attached to the mail. but when i give a variable containing the path of the file , perl is not able to send the file. ex: system('uuencode /attach/test.txt... (3 Replies)
Discussion started by: adityamahi
3 Replies

7. UNIX for Dummies Questions & Answers

Difference between mail,mailx,sendmail

Hello friends I need to know the difference between mail,mailx and sendmail commands. Thanks in advance (1 Reply)
Discussion started by: rocker
1 Replies

8. UNIX for Dummies Questions & Answers

sending mail using mailx command

Hi All, Please help me regarding sending mails using mailx command in unix. I will be glad if some one give me the sintax of this. I tried using the below but vain. mailx -s 'Hi' 'xyz@abc.com' Regards, Manas (5 Replies)
Discussion started by: manas6
5 Replies

9. Shell Programming and Scripting

sending mail through mailx

while trying to send a mail, though the output file doesn't contain any exclamatory mark(!), i am getting that in the mail with an extra line. please help me out from this ASAP. (3 Replies)
Discussion started by: pvamsikr
3 Replies

10. UNIX for Advanced & Expert Users

Problems sending Mail

Hello everybody I already read all the posts about "how to send email" but i dont find the solution, i need to send a mail via commands. Into the mail i need to attach a file.txt how can i do that? Thanx. Lestat (2 Replies)
Discussion started by: Lestat
2 Replies
Login or Register to Ask a Question