# /var/spool/mail vs .maildir setup questions?

## cayenne

Hello all,

Still trying to set up email on a new box. I'm wanting to have it replace another box with 

RH on it while I redo that box. That box had sendmail, and the mail boxes were all in

/var/spool/mail/$USER

I tracked down, and found the MAIL environment variable set in /etc/profile so that everyones email would go there. I want to bring the existing mailboxes over to the new Gentoo box. I'm guessing ont he RH box, with MAIL set to point to /var/spool/mail...that fetchmail used this to know to drop the mail there.

I looked...and Gentoo seems to be set up different. I found a /etc/profile on it..but, it appears to work with a /etc/profile.env file. I looked at it, and it appears that there are a bunch of env variables set here...but, a banner at the top said not to set this by hand, and to use the env-update command. 

As root, I tried export MAIL=/var/spoo/mail/$USER and then did env-update. When I did echo $MAIL as root...it spits out the proper /var/spool/mail/root. However, when I exited out of my su'ed root session....and as a normal user I echo $MAIL...it shows no setting.

1. Am I on the right track here that for Mutt to see my mail in /var/spool/mail/<username> I need to have this $MAIL set to point to it? 

2. If so, where to I put this so that it is universal for all users...I want all the mailboxes here.

3. I'm working on setting up postfix...in the main.cf for postfix, I did find where to set it to look at /var/spool/mail...so, guessing that should work.

4. I'm working with the email 'howto' from the forums, and am also setting up procmail, it seems to want to look at ~/.maildir too....I need to have it put things in the /var/spool/mail dir too...I guess I set MAILDIR= to point there? 

5. To have this work with postfix, procmail, and fetchmail...what permissions do I need to put on /var/spool/mail? Root owns this...can the processes write/read there..? I really don't want users to be able to get at each others email...

This is really a temp. setup, till I re-work the RH box into a Gentoo box, at which point, I'll most likely do everything like the howto says and use ~/.maildir for all users, but, the last question I'd like to know in case I come across a /var/spool/mail set up in the future.

Also, will things work if I eventually move the mailbox from the spool to a new system with .maildir? I don't want to lose that backlog of saved messages.

I'm trying to learn all this...but, moving from one style to another while preserving messages is proving a little confusing to me as I learn how email works.

Thanks in advance!!

cayenne

----------

## devon

As someone is who currently working on moving from mbox to maildir, let me share somethings I found out.  :Smile:  I use Postfix and procmail for delivery

1. I setup the following in Postfix's mail.cf

```
home_mailbox = .maildir/

mailbox_command = /usr/bin/procmail -a $DOMAIN
```

2. I edited /etc/procmailrc to be

```
DEFAULT=$HOME/.maildir/

```

3. I found a script at Freshmeat to convert from mbox -> maildir, but I haven't fully used it yet.

When I sent a test email to a user with no ~/.maildir folder, Postfix and/or procmail made one and it seemed okay. Procmail filtering seems okay too.

----------

## Pasketti

How did you get the MAIL environment variable to point to /home/user/.maildir instead of /var/spool/mail/user?  Setting it in env.d just blanked it out for me.

----------

## cayenne

 *devon wrote:*   

> As someone is who currently working on moving from mbox to maildir, let me share somethings I found out.  I use Postfix and procmail for delivery
> 
> 1. I setup the following in Postfix's mail.cf
> 
> ```
> ...

 

Thanks for the reply, but, I'm wanting to do the opposite...I want to set my MAIL variable to /var/spool/mail/$USER .....I want to use procmail, postfix and fetchmail using /var/spool/mail/$USER....NOT using /maildir

How do I set this up....I want to do this so I can just transfer my mailboxes from another box using this set up....

I can't figure out (like the post above this) how to set the MAIL variable globally for each user that logs in...I'm hoping by setting this, mutt will know where to look, as will procmail know where to put mail, and postfix will know where to get/send mail from...

Thanks in advance...

c

----------

## cayenne

 *devon wrote:*   

> As someone is who currently working on moving from mbox to maildir, let me share somethings I found out.  I use Postfix and procmail for delivery
> 
> 1. I setup the following in Postfix's mail.cf
> 
> ```
> ...

 

Thanks for the reply, but, I'm wanting to do the opposite...I want to set my MAIL variable to /var/spool/mail/$USER .....I want to use procmail, postfix and fetchmail using /var/spool/mail/$USER....NOT using /maildir

How do I set this up....I want to do this so I can just transfer my mailboxes from another box using this set up....

I can't figure out (like the post above this) how to set the MAIL variable globally for each user that logs in...I'm hoping by setting this, mutt will know where to look, as will procmail know where to put mail, and postfix will know where to get/send mail from...

Thanks in advance...

c

----------

## devon

 *Pasketti wrote:*   

> How did you get the MAIL environment variable to point to /home/user/.maildir instead of /var/spool/mail/user?  Setting it in env.d just blanked it out for me.

 

 *cayenne wrote:*   

> Thanks for the reply, but, I'm wanting to do the opposite...I want to set my MAIL variable to /var/spool/mail/$USER .....I want to use procmail, postfix and fetchmail using /var/spool/mail/$USER....NOT using /maildir

 

You all want this, right? (Or some variation)

```
$ env | egrep MAIL

MAIL=/home/devon/.maildir/

```

I added the following line to /etc/profile -- export MAIL=/home/$USER/.maildir/

----------

## cayenne

 *devon wrote:*   

>  *Pasketti wrote:*   How did you get the MAIL environment variable to point to /home/user/.maildir instead of /var/spool/mail/user?  Setting it in env.d just blanked it out for me. 
> 
>  *cayenne wrote:*   Thanks for the reply, but, I'm wanting to do the opposite...I want to set my MAIL variable to /var/spool/mail/$USER .....I want to use procmail, postfix and fetchmail using /var/spool/mail/$USER....NOT using /maildir 
> 
> You all want this, right? (Or some variation)
> ...

 

No, I want  

echo $MAIL=/var/spool/mail/<username here>

How do I set this? Where do I set this globally? I've seen others asking this, but, no answers.

----------

## devon

 *cayenne wrote:*   

> No, I want
> 
> echo $MAIL=/var/spool/mail/<username here>
> 
> How do I set this? Where do I set this globally? I've seen others asking this, but, no answers.

 

If you add "export MAIL=/var/spool/mail/$USER" to /etc/profile and doing an env-update (forgot to mention that previous post. D'oh!), does it still not work?

----------

## Pasketti

 *devon wrote:*   

> If you add "export MAIL=/var/spool/mail/$USER" to /etc/profile and doing an env-update (forgot to mention that previous post. D'oh!), does it still not work?

 

That got it.  Thanks!

I was wanting to do something different from cayenne, but he should be able to use this to do what he wants.

I did some digging, and found that the MAIL variable is set by the login program, and it's hard-coded to do it as PATH_MAILDIR/username.

Adding it to etc/profile was much easier to fix.

----------

## devon

Just a warning, I don't know if upgrading anything will overwrite that settings. I guess not since /etc should be protected... Just keep that in mind.  :Smile: 

----------

## Pasketti

I ran env-update, and it didn't overwrite it, so I figure I'm ok.

----------

## cayenne

 *Pasketti wrote:*   

> I ran env-update, and it didn't overwrite it, so I figure I'm ok.

 

This worked for me too...thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!

Mutt is looking the right place (after correcting the 'gentoo' version of /etc/mail/Muttrc with my local ~/.muttrc)

Almost all there...just trying now to figure out why mutt can't write to the /var/spool/mail/$user dir when trying to delete a message...but, the $MAIL variable is set this way...

Thanks again.

C

----------

