Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For a username "A&B"

[abuser@myserver] chfn -f "A&B"
Changing finger information for abuser
Finger information changed.
[abuser@myserver] mail -s Test
Hello World!

When this mail arrives, "&" appears to be replaced by the username in the From field in the email.

From: AAbuserB [abuser@myserver]
share|improve this question

Try with

mail -a "From: A&B <abuser@myserver>" -s Test
share|improve this answer
Thanks for the reply, but I get "mail: invalid option -- a". Furthermore, this is for an automated system email that doesn't hard-code the from address. – Nick Pierpoint Sep 9 '11 at 8:45
You seem to have a very old mail command or different implementation of it than I, then. Have you tried to escape & character: chfn -f "A\&B"? – Janne Pikkarainen Sep 9 '11 at 9:40
Yep - escaping doesn't work. – Nick Pierpoint Sep 9 '11 at 11:50

Try with Quoted Printable Encoding:

chfn -f "=?ISO-8859-15?Q?A=26B?="

where =26 is the ampersand. Looks ugly, but should do the trick.

Edit: It is not mail, but you should then try other alternatives: Use sendmail (the interface of your MTA and not sendmail itself). Or mutt is also good for scripted sending of mails. The mail command is too restricted in functionality in this case. And if you really need a mail command then you need to write a wrapper called mail that internally calls mutt for sending.

share|improve this answer
Apologies for slow reply. Doesn't seem to work... chfn -f "=?ISO-8859-15?Q?A=26B?="... chfn: full name: '=' is not allowed. – Nick Pierpoint Sep 30 '11 at 9:13
@NickPierpoint Then write a bug report for mail or use other alternatives as described in my edit. – mailq Sep 30 '11 at 12:02
I get the same behaviour using mutt - I presume the issue is with the mta (sendmail in this case). – Nick Pierpoint Sep 30 '11 at 12:58
up vote 0 down vote accepted

This behaviour is caused by the Mail Transport Agent (MTA) handling of & characters in the mailbox name in /etc/passwd

From the passwd man page:

gcos-field is the user's real name, along with information to pass along in a mail- message heading. (It is called the gcos-field for historical reasons.) An ``&'' (ampersand) in this field stands for the login name (in cases where the login name appears in a user's real name).

The workaround in this case is to explicitly set the From address in the mail client.

For example, using mutt (as suggested by @mailq):


set realname="A&B"
set from="ab@myserver"
set use_from=yes

Sending a test email...

echo "Test body" | mutt -s "Test"

Seems to work fine.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.