mailx questions

Thread Tools Search this Thread
# 1  
mailx questions

I have a few quick questions that I'm sure the experts could answer very quickly:

1. If I specify the from address in a variable it doesn't seem to work. Here is what I'm doing:
mailx -s "SUBJECT" -r "$mailFrom" etc .....

2. I'm including the output from logs in the body of an email and I'm using unix2dos for the txt file. Is there any reason to also use uuencode? I've taken a look at the documentation but I'm not sure I fully understand when it should be used ?

3. How can I include the hostname in the subject of the email ? The following doesn't seem to work:

subject="The hostname is $hostname"
mailx -s "$subject" etc .....

Thanks In Advance
# 2  
mailx does easily not support changing "from" - sendmail does
usr/lib/sendmail -t <<EOF 
Subject: I changed From:

Your mail body goes here

uuencode is used to create an "attachment" if you want - search for forums for "uuencode attachment"

hostname is a command
subject="The hostname is `hostname`"
mailx -s "$subject" etc .....

# 3  
1. What flavour of Unix id this mailx from (The man page for mailx(1) for Linux does not include a "-r" option)?

2. Uuencode(1) is only necessary for sending binary file attachments (sending an 8-bit file down a 7-bit channel).

3. The following will include the hostname in the Subject
$ mailx -s "SUBJECT `uname -n`"

$ mailx -s "SUBJECT ${HOSTNAME}"

# 4  
This is from SunOS.

Actually using -r works fine for mailx to specify the from address.

I was just trying to get the hostname using $hostname but I think I needed $(hostname). Not sure what that syntax means ?

I'm simply attaching .txt to the body of the email so I guess I don't need uuencode.

Thanks for all the answers !!
# 5  
mailx -r 'address' under some circumstances changes 'address' by deleting characters.
Thus rendering the address invalid. Or at least not what you entered.

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #986
Difficulty: Medium
The X Window System is installed by default in FreeBSD.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with Mailx

Hi , I have written below code to send email from unix. The code is getting executed fine but i am not receiving any e mail . I am not sure what is going wrong . Do we need to do any configration setting before using Mailx? Please help set -vx echo 'Sending Mail' mailx -s "SEPA_TEST"... (2 Replies)
Discussion started by: Chandru_Raj
2 Replies

2. Homework & Coursework Questions

Print questions from a questions folder in a sequential order

1.) I am to write scripts that will be phasetest folder in the home directory. 2.) The folder should have a set-up,phase and display files I have written a small script which i used to check for the existing users and their password. What I need help with: I have a set of questions in a... (19 Replies)
Discussion started by: moraks007
19 Replies

3. Shell Programming and Scripting

Mailx: How to send a attachment using mailx command

Hi All, Can anyone please provide the command for sending an mail with attachment using mailx command. Thanks in Advance :) Regards, Siram. (3 Replies)
Discussion started by: Sriram.Vedula53
3 Replies

4. Ubuntu


hi, I am working on a ksh script and i want to be able to send a email using mailx. if ] || ] then echo "send email" mailx -s "Subject goes here" <email address>; fi thats what i have so far, in place of "<email address>" I have my actualy email address and I want to add a body with... (6 Replies)
Discussion started by: mike509123
6 Replies

5. UNIX and Linux Applications


Hi, I am not able to send direct mails from our unix server to our lotus notes id. It was fine until we upgrade our Lotus notes server. What are the changes need to add when we upgrade Lotus notes. Please advice. It run in sh file This is the statement uuencode $RTDIR/$filename... (0 Replies)
Discussion started by: rajani_p
0 Replies

6. HP-UX

mailx help

Hi, I have a shell script which has code like: cat /tmp/MAIL_PCSD | mailx -m -s " PEWA Order Acknowledgement" $M1 and M1 is nothing but this M1=`echo $x | awk ' {print $3}' ` If I pass absolute email address to $M1 it works fine. But, the thing is that it gets $M1 by reading some... (3 Replies)
Discussion started by: isingh786
3 Replies

7. UNIX for Dummies Questions & Answers

mailx error message : mailx: NUL changed to @

If I use the "Mail" link instead of the "mail" link to ../mailx I get this error. Mail so-n-so mailx: NUL changed to @ Unknown command: "postmaster" The email still goes through but i get the error. If I use "mail" it goes thru without the error. Any ideas?? (2 Replies)
Discussion started by: BG_JrAdmin
2 Replies

8. UNIX for Dummies Questions & Answers

Help with mailx

I want to send a message with an attachment from Unix using the following command: uuencode $DIRNAME/$FILENAME1 | mailx -s "test subject" xyz@xyz I need to attach the file and I also want a simple message body like "there is an error. Please check it". Do I need to have this message body... (1 Reply)
Discussion started by: ssmith001
1 Replies

9. Shell Programming and Scripting


I am trying to write a shell script using the mailx command. My problem is that I want to send an email address in the CC: field. What option can I use with mailx to accomplish this. Any help would be very appreciative. (1 Reply)
Discussion started by: skammer
1 Replies

10. UNIX for Dummies Questions & Answers

Need help with mailx

How can I send a file of Unix usernames to everyone on the file without making an alias in my .mailrc file? Using a mailx command. Thanks, J.J. (2 Replies)
Discussion started by: JJJ
2 Replies

Featured Tech Videos