mailx change sender name

16,404

Solution 1

mailx -a 'From:[email protected]' -s "Subject" [email protected] < text.txt

Solution 2

The correct syntax is:

mailx -s "some subject" [email protected] -- -r [email protected]

The Usage info shows "[-- sendmail-options ...]" and since "-r" is a sendmail option, you need to use the double dashes first.

Solution 3

Tested with this and found to be working:

echo test | mailx -s "Mail Test" [email protected] -- -f [email protected]

The double-dash before "-f" makes the mailx not to parse the -f, but only pass it to sendmail/postfix, which will then send with the "from" address mentioned.

Share:
16,404
hudac
Author by

hudac

Updated on September 16, 2022

Comments

  • hudac
    hudac over 1 year

    I understood that for changing sender's name with mailx I should do the following:

    mailx -r [email protected] -s "some subject" [email protected]
    

    But when I do that, I get:

    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
    

    Does anyone knows what's happening? thanks,