4

When I send email using /usr/bin/mail on the command line (Ubuntu 13.04 64-bit), it does not pay attention to any aliases in my .mailrc file. Does anybody know how to fix this?

To reproduce the problem:

  1. Put an alias in $HOME/.mailrc

    alias foo [email protected]

  2. Try to mail the alias:

    $ echo hello | /usr/bin/mail -s testing foo

  3. Read /var/log/mail.log and see "foo" bounce as an unknown user:

    Sep 7 11:15:39 mycomputer postfix/local[9707]: EE038F6028B: to=<[email protected]>, relay=local, delay=0.1, delays=0.07/0/0/0.03, dsn=5.1.1, status=bounced (unknown user: "foo")

However, my other mail programs, such as Emacs VM, respect the aliases in $HOME/.mailrc.

This didn't used to happen in Ubuntu 10.04 LTS, my previous system.

On further investigation... I ran:

$ mail -f mymailbox
? alias foo
foo        [email protected]

So /usr/bin/mail is indeed processing $HOME/.mailrc, but somehow, even though "mail" knows the alias "foo", the result is that postfix sees an email message to "[email protected]" instead of the alias expansion. I don't know who's misconfigured: mail (GNU mailutils) or postfix.

3
  • 1
    Have you tried using mailx instead?
    – mdpc
    Sep 7, 2013 at 18:14
  • On my system, /usr/bin/mailx and /usr/bin/mail are both symlinks to the same executable, /usr/bin/mail.mailutils. So I get the same behavior.
    – DanB
    Sep 8, 2013 at 14:48
  • So, I installed the Ubuntu package "bsd-mailx", which provides a real mailx. The problem does not occur! Alias "foo" expands properly so the mail is sent to [email protected].
    – DanB
    Sep 8, 2013 at 14:53

4 Answers 4

3

I did:

sudo apt-get install bsd-mailx

and the problem went away. The mail programs provided by bsd-mailx support .mailrc aliases, while apparently the ones in mailutils do not.

Credit to mdpc (https://askubuntu.com/users/5863/mdpc) for leading me to this solution in his comment above.

2

From my recollection....the mail program is a bare bones local mail delivery agent and is generally called from programs such as sendmail. I have found that the mailx program is the more user friendly program that has a lot more whistles and bells. If I recall mailx is available and can be used on nearly all Linux/UNIX systems.

I got into the habit of using mailx over mail way back in the Solaris days.

2

So bsd-mailx may not have this problem; but, it also has a lot fewer features than gnu mailutils.

I also ran into this problem recently on a new Ubuntu install; but, discovered that the following in my ~/.mailrc fixed the problem:

set inplacealiases

That's it. Aliases worked after I did that.

-1

After you have installed the mail server using something like sudo apt-get install mailutils and created the aliases file, you need to let the system read and create a hash file of the aliases configuration.

sudo newaliases

Changing the aliases file without running the above command afterwards will not make any changes for the system.

This post might be relevant to your question.

1
  • That may be true for a system-wide aliases file, but not for $HOME/.mailrc.
    – DanB
    Dec 14, 2020 at 21:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .