How to get mailx to use return address from Linux

Posted on 2009-04-24
Last Modified: 2013-12-18
We are moving scripts from a Solaris 9 server to a Linux server.  We are having a problem with certain phone providers not sending/receiving emails or pages unless a return address is sent.  This worked on Solaris by executing:
mailx -r -s "ORA Error : `uname -n` : $ORACLE_SID" orapage > /dev/null < $l_log
On Linux we are using Postfix and it has been configured to look like sendmail.  Also, this code is inside a ksh script running in a bash environment.
Is there a simple way for me to get this to work on Linux?

Please assign to the correct zone as needed?

Question by:dmn9165dnelson
    LVL 26

    Expert Comment

    Try this:

    echo "Hi there" |mailx -s "This is your subject" -r

    where sender is your return address "From:" and reciepient is your "To:" address.


    Author Comment

    I have tried many of these types of examples and it does not work.  Here is the output from running your example.
    mailx: 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]

    This should be easy, but the way they have the server setup, it makes it more complicated.  Linux server, where they are using Postfix but it is configured to look like sendmail.  Linux does not support the -r option for mailx.  All other articles that I have read say to use sendmail.  Is there a simple way to do this?
    LVL 26

    Expert Comment

    What flavor of your Linux server? Version? Some Linux use mail instead of mailx
    Did you make sure mailx is available in the bin directory?
    Did you do full path to where mailx resides? the previous post, I assumed that you were in the /usr/bin
    If mailx is not existed on your server, download and put it in /usr/bin then cd to /bin and try my previous command.


    Accepted Solution

    The way that our servers are configured, we had to use sendmail to be able to page certain group members.  Their phone carrier required a return address in order to send the page.  Here is what we ended up doing, for anyone interested:

       echo "SUBJECT: REVIEW needed on $hostid - chk4unixgroups" | cat - $WORKPATH/$hostid.chk4unixgroups.msgtxt \
               | /usr/lib/sendmail -f `cat $maillist`


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    this article is a guided solution for most of the common server issues in server hardware tasks we are facing in our routine job works. the topics in the following article covered are, 1) dell hardware raidlevel (Perc) 2) adding HDD 3) how t…
    New-MailboxSearch Powershell Command and step by step approach to Search and Extract Emails form Exchange 2013 Journaling server.
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
    This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

    761 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