13

When I type mail command, I get a "No mail for USER" answer, but there's indeed mail (it's in /home/USER/Maildir/new)

I guess it has something to do with the mailbox being in Maildir format, instead of mbox, but I don't know how to tell mailutils (specifically the mail command) which format to use.

luri
  • 4,142

3 Answers3

9

Afaik "mail" utility checks mails at the location given with the MAIL environment variable. Try this command: MAIL=/home/USER/Maildir/ mail (for sure, replace USER with something meaningful & valid). If that works, it seems that you should set MAIL variable you can do it in your bash profile / rc file for example. You can check the content of your current MAIL variable with: echo $MAIL

LGB
  • 1,587
  • I did not say nautilus, but mailutils (similar, tho :) ) – luri Feb 14 '11 at 13:08
  • Arghhh, I haven't slept too much, I must admit :) Okei, and sorry for the misread, however what I told (the other parts than nautilus, hehe) is still valid. But after this nasty mistake, I am not sure anymore :-@ – LGB Feb 14 '11 at 13:12
  • OK... if I set MAIL=/home/USER/Maildir/ mail, I get the right number of mails, and I can read them... BUT upon reading mails, 'mail' command will move them from /home/USER/Maildir to /home/USER/mbox.... wich doesn't exist, so, as a matter of fact, it did erase them (just test mails, so no worries). But shouldn't it realize where and how mail is stored (btw I have postfix and courier working). – luri Feb 14 '11 at 13:14
  • Update: my bad, it does not move mail to /home/USER/mbox folder. It's a file, that contains the mails in text format... But anyway it renders them unusable for Courier, that seeks a Maildir schema. – luri Feb 14 '11 at 13:42
  • "text file format"? Then it's the "standard" "unix mailbox" file format, which is just one file (as opposite to the maildir) containing every mails. But I am not sure now, if you write that "it does not move mails" then what's the problem, if mails were not moved, your mails are still in your maildir (/home/USER/Maildir), isn't it? Or have you missed check /home/USER/Maildir/cur/ ? Maildir has cur/ and new/, new contains the unread mails, cur the read ones. Maybe "mail" utility moved your mails into /cur, since they are not new anymore. That is the good behavior, maildir works this way! – LGB Feb 14 '11 at 13:50
  • They aren't in either Maidir/new or Maildir/cur.... they're deleted from there (not just moved from and written to the 'mailbox file', where courier can't access them. The issue is, then, if there is a configuration file for mailutils where I can set up 'mail' command to use Maildir schema by default, not having to set the MAIL environment variable (which would be a minor problem, anyway), and avoiding the erasing (well, erasing in practice for me, though they're really moved to an 'mbox' mailbox) of read mails. – luri Feb 14 '11 at 22:34
  • I would add the global variable as MAIL = ~/Maildir – LinuxBill Mar 06 '13 at 14:47
4

To fetch mail from users home directory, use mail with -f option

 mail -f /home/USER/Maildir/
storm
  • 5,023
0

This will configure mailutils for the current user to use Maildir:

printf "mailbox {\n  mailbox-pattern maildir://${HOME}/Maildir/;\n}\n" >> "${HOME}/.mail"

note

Although this does let you read the mail from Maildir, it still causes mail which has been read to get moved to mbox in the user's home directory.

Alternatively, don't configure .mail and just invoke using Maildir directly:

mail -f "maildir://${HOME}/Maildir/"

If you do this it seems to work as expected. Tested on this version:

% mail --version
mail (GNU Mailutils) 3.17
davejagoda
  • 146
  • 6