3

I want to use the mailutils app on a install of Ubuntu 12.04.3 LTS with a Maildir format, but every time I run the mail command, the system looks in /var/mail/user, instead of the Maildir directory in the home folder.

I'm aware that setting the MAIL variable will resolve this, however the changes only last until the user logs out. How can I make this permanent?

In addition, how do I configure mail to not save messages into the mbox file in the user's home folder, but rather keep everything in Maildir?

6

Fixing the variable

If you'd like to make this change system wide I'd be inclined to add an entry in the directory /etc/profile.d for it. You can simply put a file in there with the contents as follows:

# /etc/profile.d/mailenv.sh
MAIL=$HOME/Maildir

or

MAILDIR=$HOME/Maildir

This environment variable, $HOME, should be in scope when the user logs in. We're putting this entry in /etc/profile.d so that it gets sourced when a user logs in, into their shell's environment. From then on, any subsequent "interactive" shells they may spawn will inherit the environment variable from the original parent shell.

mu-tool

You can also install the mailutils package:

$ sudo apt-get install mailutils

Which includes the tool mu-tool. The following command will show your mail setup.

$ mu-tool info
VERSION=2.99.97
SYSCONFDIR=/etc
MAILSPOOLDIR=/var/mail/
SCHEME=mbox
LOG_FACILITY=mail
IPV6
USE_LIBPAM
HAVE_LIBLTDL
WITH_GDBM
WITH_GNUTLS
WITH_GSASL
WITH_GSSAPI
WITH_GUILE
WITH_PYTHON
....

Consolidating mbox

I don't think you want to do this. When dealing with mail there are usually 2 locations that you need to have. The first is often referred to as the spool or "post office". This is a location where the mail server can deliver mail. The other is your mailbox (aka. mbox).

The mail man page hints at this too:

 /var/mail/*                  post office (unless overridden by the MAIL
                              environment variable)
 ~/mbox                       user’s old mail

When the same server is tasked with spooling the mail, and allowing the user to read the mail, then these 2 directories will reside on the same box, in different locations. When reading the mail using something like POP or IMAP the "post office" will reside on that server and your mailbox will reside locally on whatever client you happen to be using.

References

  • @NoelForte - NP, thanks for the Q. Good luck with your continued setup! – slm Jan 21 '14 at 2:46
  • Oh, one more thing. Would you suggest using Maildir as the "post office"? Mail gets stored in /home/user/Maildir obviously, but I'm planning on using Roundcube webmail, so I don't know whether one way is better than another. Really new at this stuff– feel like I'm in the dark. – Noel Forte Jan 21 '14 at 5:45
  • Additionally, the terminal says that mu-tool isn't a valid command, even after installing mailutils. – Noel Forte Jan 21 '14 at 6:10
  • @NoelForte - I always leave the "post office" under /var/spool/mail/$USER on my systems. But I run a centralized Sendmail server setup, w/ IMAP (Dovecot) and Roundcube. – slm Jan 21 '14 at 6:59
  • @NoelForte - I'm on 12.10 Ubuntu and mu-tool is part of mailutils. Try a apt-cache search mu-tool. – slm Jan 21 '14 at 7:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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