Change "From address" with the mail command

Despite what the man page says, and what I have read out on the web, I cannot get the mail command to let me change the “from address”

I have tried to change the reply address (-R my@address.com)
I have tried to change the from address (-f my@address.com)
… and so on

Anyone have any luck, from the command line (as I am setting up cron jobs) in changing the “from” address?

echo test | mail -s “This is a test” user@domain.com (this is the basic command I wish to use, but change the “from address”)

Hi
It’s -r not -R to set the ‘From’ address.


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.32.24-0.2-default
up 1:37, 2 users, load average: 0.14, 0.10, 0.08
GPU GeForce 8600 GTS Silent - Driver Version: 260.19.21

As far as I remember only a “trusted” user can do this. For sendmail they are listed in /etc/mail/trusted-users; for postfix: I don’t know.

Anybody can do this with sendmail. But for an untrusted user, an “X-Authentication-Warning:” header is added.

Note that I just tested, and it is fine.

I don’t know what happens with postfix, though I might experiment later today.

I used: mailx -rsender@hostname recipient

Anybody can do this with sendmail. But for an untrusted user, an “X-Authentication-Warning:” header is added.

Correct. Thanks for refreshing my memory.

On 2010-12-06 13:36, nrickert wrote:

> I don’t know what happens with postfix, though I might experiment later
> today.

It doesn’t matter if you are using mailx. It would, perhaps, if you used
sendmail (postfix has a small sendmail binary for compatibility).


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

echo test | mail -s test -r me@mydomain.com me@mydomain.com
send-mail: illegal option – r
sendmail: usage: sendmail -t ] -fsender ] -Fname ] -bp ] -bs ] arg … ]

Can you do it with just mail, and not mailx?

I am not using postfix or sendmail. I am using qmail. Anything I need to tweak for that?

Can you do it with just mail, and not mailx?

> ls -l /usr/bin/mail
lrwxrwxrwx 1 root root 5 Sep 24 10:18 /usr/bin/mail -> mailx

Yes, you can. The ‘mail’ command is a symbolic link to ‘mailx’. A command may behave different according to the name under which it is called, but with mailx it should make no difference.

You can also set the ‘from’ variable instead of using the -r option. (man mailx).

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Works for me:

echo test | mail -r ab@novell.com -s ‘test subject’ ab@novell.com
2010-12-06 09:49:57 Jobs:0 Err:0

Maybe the version of mail/mailx you are using.

<quote>
ab@mybox0:~/Desktop> rpm -qif which mail
Name : mailx Relocations: (not relocatable)
Version : 12.2 Vendor: openSUSE
Release : 150.2 Build Date: Mon 05 Jul 2010
10:54:22 AM MDT
Install Date: Mon 05 Jul 2010 11:42:52 PM MDT Build Host: build33
</quote>

OpenSUSE 11.3 x86_64 with latest patches.

Good luck.

On 12/06/2010 09:06 AM, joharmon wrote:
>
> malcolmlewis;2262213 Wrote:
>> Hi
>> It’s -r not -R to set the ‘From’ address.
>>
>> –
>> Cheers Malcolm °¿° (Linux Counter #276890)
>> SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.32.24-0.2-default
>> up 1:37, 2 users, load average: 0.14, 0.10, 0.08
>> GPU GeForce 8600 GTS Silent - Driver Version: 260.19.21
>
> echo test | mail -s test -r me@mydomain.com me@mydomain.com
> send-mail: illegal option – r
> sendmail: usage: sendmail -t ] -fsender ] -Fname ] -bp ] -bs
> ] arg … ]
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJM/RShAAoJEF+XTK08PnB5HK4QAJJVGrjF62l3zFd8BnDqo1bS
aJT1eGTg55cZt4ZKXbmcuGJ+VDlJIDaRMTm74qP1AGFyZp8WJCnKmcpLfF1rQK1F
NIvWuMFwoZnG0wSx6yYkB6Z9XqY1Gj6Nlq8gNuDgBVzmw1T8VjzvG+miZXj9fwtj
kIK09XrgSAqiVArDEN+FXvFS3wTN+zzPMXZpaOWG9A/t0UUWbl4a3IK/B31jf1Kv
NIS/koSRUgBznajoKgrvon5uPG3peQ7akdHO04Xbt9pacVYATmHwyDAFRciLL5cy
7n51CCv9y5xIQL6+pfGbb1ZArVrxX9Jj7MwegXgjkl0lybYN00h4EyX6SSlqMphQ
BfcLtJJ7Dd82w/kE814YlXZ7hgsaEYnCHZGLet5jQZw/rbaRwGzpbk82Do7wkipW
shigTidD3Wphg3P6FHrUPULEf8AK4otCd4K+pCPpHsHjgn8JZiBCwTmssoTtKdqz
n++xp2ciDMLmajRJEi5Mvf30O5Z++LzH/Yqt1uMlFNI+aFCo58yxI5PExZsNDP8T
49OoYtFWUB4e6PcyG30NeKiHHAdrQQbJyZVHlBQsz84WJp+ruiy/26NGUI9BacY8
2LeQHrkvEg6uOrAzkaTP91GBsqBJEfK2+VnHAs1bWWz5eflo5lPwkOOvuuhZLj6f
T82h2g7fmZfLc0sWYOZ4
=3swt
-----END PGP SIGNATURE-----

On 2010-12-06 17:06, joharmon wrote:

> echo test | mail -s test -r me@mydomain.com me@mydomain.com
> send-mail: illegal option – r
> sendmail: usage: sendmail -t ] -fsender ] -Fname ] -bp ] -bs
> ] arg … ]

Check your installation. That is not the correct mail program.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

On 2010-12-06 17:06, joharmon wrote:

> Can you do it with just mail, and not mailx?

No, and yes.

cer@Telcontar:~> which mail
/usr/bin/mail
cer@Telcontar:~> l /usr/bin/mail
lrwxrwxrwx 1 root root 5 2010-09-21 04:33 /usr/bin/mail -> mailx*


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)