Mailx and the From Line

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Mailx and the From Line
# 1  
Old 12-27-2007
Mailx and the From Line

I need to send an email from one server and make it look like it came from someone else because I dont check the mail on the production server if there is a reply. I have been over the man pages for mailx and I am just running in circles. Which option should I use to be able to do this?
# 2  
Old 12-27-2007
use sendmail directly or whatever MTA you have installed. This way you can add whatever headers you need.
# 3  
Old 12-29-2007
I don't use this all the time, but some of our email distribution processing uses the following...
$ cat $CC_BATCH/ | more

# Initialize sent flag
echo 'Reply-To: '$REPLY_ADDR >$TMP_PATH_FILE
echo 'To: '${TO_ADDR} >>$TMP_PATH_FILE
echo 'Cc: '$CC_ADDR >> $TMP_PATH_FILE
echo 'From: '$FROM_ADDR >> $TMP_PATH_FILE
echo 'Mime-Version: 1.0' >>$TMP_PATH_FILE
echo 'Subject: '$SUBJECT >>$TMP_PATH_FILE
echo 'Content-Type: multipart/mixed; boundary="PARTBOUNDARY"' >>$TMP_PATH_FILE
echo 'Content-Type: text/plain; charset="us-ascii"' >>$TMP_PATH_FILE
echo 'This mail has an attachment' >>$TMP_PATH_FILE
echo 'Content-Description: Text' >>$TMP_PATH_FILE
echo 'Content-Type: text/plain; charset="us-ascii"' >>$TMP_PATH_FILE
echo 'Content-Disposition: attachment; filename="'$ATTACH_FILE_NAME'"' >>$TMP_PATH_FILE
        if [ -s $ATTACH_FILE ]
                cat $ATTACH_FILE >>$TMP_PATH_FILE
                echo >>$TMP_PATH_FILE
        echo '--PARTBOUNDARY--' >>$TMP_PATH_FILE

# main script
# setup environment
# Check if lock File from req_proc exists
# get params

if [ 1 ]
echo '**** Email Dispatch process commencing' `date` '****' >> $EML_LOG_FILE

        if [ "$TO_ADDR" = "" ] || [ "$FROM_ADDR" = "" ] || [ "$REPLY_ADDR" = "" ] || [ "$SUBJECT" = "" ] || [ "$ATT
ACH_FILE" = "" ] || [ "$EML_LOG_FILE" = "" ];
                echo "ERROR: Argument missing for email_dispatch script." >> $EML_LOG_FILE
                echo "TO_ADDR"      $TO_ADDR      >> $EML_LOG_FILE
                echo "FROM_ADDR"    $FROM_ADDR    >> $EML_LOG_FILE
                echo "REPLY_ADDR"   $REPLY_ADDR   >> $EML_LOG_FILE
                echo "SUBJECT"      $SUBJECT      >> $EML_LOG_FILE
                echo "ATTACH_FILE"  $ATTACH_FILE  >> $EML_LOG_FILE
                echo "EML_LOG_FILE" $EML_LOG_FILE >> $EML_LOG_FILE
                echo '**** Email Dispatch process completed' `date` '****' >> $EML_LOG_FILE
                return 1

        ATTACH_FILE_NAME=`echo $ATTACH_FILE | sed '1,$s/.*\///'`

        if [ -f $TMP_PATH_FILE ]
                echo "Error: Temporary file exists. "$TMP_PATH_FILE >> $EML_LOG_FILE
                echo '**** Email Dispatch process completed' `date` '****' >> $EML_LOG_FILE
                return 1
                > $TMP_PATH_FILE

        # Mail file
        sleep 1
        mail ${TO_ADDR},${CC_ADDR} < $TMP_PATH_FILE >> $EML_LOG_FILE
        sleep 1

        # Clean up
        rm $TMP_PATH_FILE >> $EML_LOG_FILE

        echo '**** Email Dispatch process completed' `date` '****' >> $EML_LOG_FILE
fi 2>> $EML_LOG_FILE

And would be called from another script ...
.. .. ..
        # Alter Attachment and Subject Title details for outgoing email.
        export EML_LOG_FILE=$LOG

        export SUBJECT=' Your Subject Goes Here '

        # Dispatch email.
        echo 'Dispatching Email...' >> $LOG
        if [ $EML_RESULT = 0 ]
                echo 'Email dispatch successful.' >> $LOG
                echo '*** Error: Email failed !' >> $LOG
.. .. ..

Hope the above is of some help for you. Smilie

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies

2. UNIX for Beginners Questions & Answers

Variable not displaying in subject line of mailx email

Hi Newbie here with first post. I've got a shell script (ksh) whereby I run a SQL*Plus script and output the results to a file. I then check the output file in an if statement that looks like this: if ]; then export GAPNUM=`awk '{print $4}' $OUTFILE` if ] then mailx -s... (10 Replies)
Discussion started by: ltzwoman
10 Replies

3. Shell Programming and Scripting

Mailx appending exclamation mark and newline in a long line

Hi, I have a shell script which automates reporting and at times, requires the report line to be very long (sometimes as long as 2131 chars). The output I get is similar to this: XXXX XXXXXXX 16:15 3.24% 5.07% 3.69% 5.23% 3.68% 4.06% 3.57% 5.03% 4.31% 5.11% 3.49% 4.19% 4.31% ... (2 Replies)
Discussion started by: gilberteu
2 Replies

4. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 Replies

5. Shell Programming and Scripting

how to read the contents of two files line by line and compare the line by line?

Hi All, I'm trying to figure out which are the trusted-ips and which are not using a script file.. I have a file named 'ip-list.txt' which contains some ip addresses and another file named 'trusted-ip-list.txt' which also contains some ip addresses. I want to read a line from... (4 Replies)
Discussion started by: mjavalkar
4 Replies

6. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

7. Shell Programming and Scripting

executing/including command in mailx subject line

Hi, Is it possible for me to include the results from a command in the subject line? What I am looking to do is get the file count and include it into the subject line as well as the list of files in the body. Example Subject line: Currently 25 files in directory My Code: #!/bin/ksh cd... (2 Replies)
Discussion started by: ozifer
2 Replies

8. 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

9. 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

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
Login or Register to Ask a Question