# Want /var/spool/mail instead of ~/.maildir !!

## maverick6664

Title says it all.

I moved from Debian/RedHat to Gentoo just 2 days ago, and having this problem.  I'm accustomed to /var/spool/mail structure (what is it called?) because I like to use pop daemon or mailx to read email, but by default, Gentoo uses ~/.maildir way.   How can I change it to /var/spool/mail way?

I've been looking for it with google, but I've not found the solution yet, asking this here  :Smile: 

I'm using sendmail/procmail/mailx, and my sendmail.cf and submit.cf are the default ones;ie, copied from /usr/share/sendmail-cf/cf (generic-linux.cf and submit.cf)

Thanks in advance!!  :Wink: 

----------

## msalerno

Just a guess, but do you have mbox in your use flags?

Taken from: http://www.gentoo.org/dyn/use-index.xml  (Required Reading)

mbox            Adds support for mbox (/var/spool/mail) style mail spools

----------

## maverick6664

 *msalerno wrote:*   

> Just a guess, but do you have mbox in your use flags?
> 
> Taken from: http://www.gentoo.org/dyn/use-index.xml  (Required Reading)
> 
> mbox            Adds support for mbox (/var/spool/mail) style mail spools

 

bingo!!  I haven't added it in use flags.

Thank you!!  :Smile:   I wonder why I could not find it with google....or should I search use flags at first?

BTW what's the advantage of using .maildir structure over mbox style?

----------

## maverick6664

oops  :Shocked: 

I added "mbox" in the use flags, but it doesn't use /var/spool/mail.  mail comes in .maildir (though I don't use maildir flag.)   Why does it happen?   I recompiled mailx, sendmail, procmail with "mbox" in use flags.  I once unmerged them all and merged them again.  Should I recompile other packages?

For ref, my /etc/make.conf is

```

# These settings were set by the catalyst build script that automatically built this stage

# Please consult /etc/make.conf.example for a more detailed example

CFLAGS="-O2 -march=pentium4 -fomit-frame-pointer -pipe"

CHOST="i686-pc-linux-gnu"

CXXFLAGS="${CFLAGS}"

GENTOO_MIRRORS="ftp://ftp.ecc.u-tokyo.ac.jp/GENTOO/ http://mirror.gentoo.gr.jp/ http://gentoo.gg3.net/"

USE="cjk unicode mmx sse mbox samba sasl apache2 dvd dvdread"

LINGUAS="ja"

```

TIA!!

----------

## msalerno

Like I said in my first post, this is just a guess, but according to the docs, it should work.

Try a:

emerge -Np world

Taken from the maildir man page:

 *Quote:*   

> Traditionally, E-mail folders were saved as plain text files, called ``mboxes''.  Mboxes have known limitations.  Only one  application
> 
> can  use  an  mbox  at  the same time.  Locking is required in order to allow simultaneous concurrent access by different applications.
> 
> Locking is often problematic, and not very reliable in network-based filesystem requirements.   Some  network-based  filesystems  don't
> ...

 

----------

## rex123

I suspect that, by default, the mbox format mail is stored in /var/spool/mail/[username]

The application to concentrate on is sendmail, which (I assume) is the application that is actually delivering the mail to the mailbox, in whatever format is required.

If you have both maildir and mbox USE flags, that might confuse it. Try emerge -pv sendmail, and look at the USE flags that are listed. You might want to have -maildir in your USE string.

[I think maildir is a big improvement on mbox, but mailx probably won't read it - you'll need mutt or pine etc]

----------

## maverick6664

Thank you!!...I need a bit time  :Smile:   I'm doing "emerge -DNu world"

I still like mbox, so I added -maildir, and recompiled procmail, sendmail, mailx, but in vain yet.  But if it still fails, I will try exim, or abandon mbox...but now that mbox/maildir use flags are available, mbox must be enabled in some way..

Gentoo looks like my good fit  :Wink: 

----------

## maverick6664

 *rex123 wrote:*   

> I suspect that, by default, the mbox format mail is stored in /var/spool/mail/[username]
> 
> The application to concentrate on is sendmail, which (I assume) is the application that is actually delivering the mail to the mailbox, in whatever format is required.
> 
> If you have both maildir and mbox USE flags, that might confuse it. Try emerge -pv sendmail, and look at the USE flags that are listed. You might want to have -maildir in your USE string.
> ...

 

Thank you for the hint (and nice options of emerge).  I examined with "emerge -pv procmail" and "emerge -pv sendmail" and they said:

sorry...I've made a mistake...now confirming it and will post reply  :Smile: 

----------

## rex123

Sorry if I've confused you. I don't use sendmail, and I don't use mbox, so perhaps I should have kept out of it.

----------

## maverick6664

I abandoned sendmail and switched to exim.  Looking at /var/log/messages, it seems to be working!!  but alas!  the permissions of /var/mail (symlink to /var/spool/mail.  am I correct?) is wrong and I cannot receive mail!!  I made /var/mail and /var/spool/mail manually because "emerge exim" didn't make it.

```

in /var/log/messages

May 17 02:18:37 maverick exim[7207]: 2005-05-17 02:18:37 1DXjEj-0001sE-3J == tetsuji@maverick.h1x.com R=localuser T=local_delivery defer (13): Permission denied: creating lock file hitching post /var/mail/tetsuji.lock.maverick.h1x.com.4288d5ed.00001c28 (euid=1000 egid=1000)

and

bash-2.05b# ls -al /var/spool/mail

total 8

drwxrwxr-x  2 root mail 4096 May 17 02:21 .

drwxr-xr-x  9 root root 4096 May 17 02:09 ..

```

What's the correct permissions and owner/group for /var/spool/mail?  I need email because I must receive any system errors/warnings by email.

I hope I'm getting close  :Smile: 

TIA!

Now one problem is sendmail/procmail doesn't work for mbox format, while exim works fine with the same use flags (I added "-maildir mbox".)  It may be because of my ignorance though.

----------

## msalerno

I don't use exim, but I would try setting the owner of ./mail to the user that runs the exim service.

Or you could set ./mail to 777, send a mail and see what the permissions of the lock file or mbox are and then changing the owner and permissions to something a bit more secure.

----------

## maverick6664

 *msalerno wrote:*   

> I don't use exim, but I would try setting the owner of ./mail to the user that runs the exim service.
> 
> Or you could set ./mail to 777, send a mail and see what the permissions of the lock file or mbox are and then changing the owner and permissions to something a bit more secure.

 

Yes, I did it and succeeded  :Smile:    ie; mkdir /var/spool/mail, and "chmod 777 /var/spool/mail", "chown mail:mail /var/spool/mail" and "ln -s /var/spool/mail /var/mail"

but it's very insecure and it's not supposed to be  :Smile: 

When I change permissions of /var/spool/mail to 775, it fails because of "permission denied"   And exim is running with uid=8 (mail).  So I wonder why exim fails to write in /var/spool/mail.

EDIT:

I examined a backup debian partition and found in /var/spool/mail.

```

bash-2.05b# ls -al

total 8

drwxrwxr-x  2 mail    mail    4096 May 17 02:37 .

drwxr-xr-x  9 root    root    4096 May 17 02:27 ..

-rw-------  1 tetsuji tetsuji    0 May 17 02:37 tetsuji

```

I think I need sleep.  :Smile:    good nite and see you later  :Smile: 

----------

## maverick6664

Finally I DID IT!!

I just happened to see inside /etc/procmailrc

```

# Use maildir-style mailbox in user's home directory

DEFAULT=$HOME/.maildir/

```

inspite of "-maildir mbox" flags.  So I changed it to

```

# Use maildir-style mailbox in user's home directory

#DEFAULT=$HOME/.maildir/

DEFAULT=/var/spool/mail/

```

and it succeeded!!  As a matter of course, permissions of /var/spool/mail is

```

maverick:~% ls -al /var/spool/mail

total 12

drwxrwxr-x   2 mail    mail    4096 May 17 03:07 .

drwxr-xr-x  10 root    root    4096 May 17 03:00 ..

-rw-------   1 tetsuji tetsuji  604 May 17 03:10 tetsuji

```

CHEERS!!!

Thank you all for hints and nice usage of emerge.  This forum is very nice.

Gentoo is my fit!!  :Laughing:    It's very easy to debug unlike other distros.

----------

## rex123

Glad it worked out. exim is an excellent piece of software (just to add my anti-sendmail prejudice).

----------

## Incabulos

I was having the same issue. As well as remerging sendmail with +mbox ( and also +mailwrapper ) I replaced the sendmail.mc's as well - overwrote old template with the new one, then merged my additions back into it and regenerated sendmail.cf. This did the trick, I didnt need to tweak procmail at all.

HTH.

----------

