local transport: how to automatically create Maildir

2015-04-30 Thread Алексей Доморадов
 Hello,

I'm using local transport and system user with maildir. But when I sent mail in 
the log I see the following error

Apr 30 08:01:15 jira-srv01 postfix/local[20496]: warning: perhaps you need to 
create the maildirs in advance
Apr 30 08:01:15 jira-srv01 postfix/smtpd[20530]: disconnect from 
mail-la0-f51.google.com[209.85.215.51]
Apr 30 08:01:15 jira-srv01 postfix/local[20496]: 138F12002D4: 
to=webmas...@example.net, relay=local, delay=0.28, delays=0.21/0/0/0.07, 
dsn=5.2.0, status=bounced (maildir delivery failed: create maildir file 
/var/spool/mail/webmaster/tmp/1430380875.P20496.jira-srv01: Permission denied)

If I create dir manually and set corresponding permissions - all works fine

# mkdir /var/spool/mail/webmaster/
# chmod -R 700 /var/spool/mail/webmaster/
# chown -R webmaster:webmaster /var/spool/mail/webmaster/

Apr 30 08:03:07 jira-srv01 postfix/smtpd[20629]: disconnect from 
mail-la0-f46.google.com[209.85.215.46]
Apr 30 08:03:07 jira-srv01 postfix/local[20632]: DE9AF2002D4: 
to=webmas...@example.net, relay=local, delay=0.24, delays=0.19/0/0/0.05, 
dsn=2.0.0, status=sent (delivered to maildir)

# ls -la
total 20K
drwx--    5 webmaster webmaster 4.0K Apr 30 08:59 .
drwxrwxr-x 3 root         mail        4.0K Apr 30 08:01 ..
drwx--    2 webmaster webmaster 4.0K Apr 30 08:59 cur
drwx--    2 webmaster webmaster 4.0K Apr 30 08:59 new
drwx--    2 webmaster webmaster 4.0K Apr 30 08:59 tmp

But it's very uncomfortable to create maildir for each user manually. Are there 
any workaround?

P.S.
CentOS 6, postfix-2.6.6

Thanks in advance


Re: local transport: how to automatically create Maildir

2015-04-30 Thread Koko Wijatmoko
On Thu, 30 Apr 2015 12:12:33 +0300
Алексей Доморадов alex_...@mail.ru wrote:

 But it's very uncomfortable to create maildir for each
 user manually. Are there any workaround?
 
set home_mailbox to Maildir/, and create Maildir/{cur,new,tmp}
at directory /etc/skel/, so on next adduser/useradd it will be
automatically create the correct requirement for maildir style inbox.

from main.cf:

# DELIVERY TO MAILBOX
#
# The home_mailbox parameter specifies the optional pathname of a
# mailbox file relative to a user's home directory. The default
# mailbox file is /var/spool/mail/user or /var/mail/user.  Specify
# Maildir/ for qmail-style delivery (the / is required).
#
#home_mailbox = Mailbox
#home_mailbox = Maildir/


Re[2]: local transport: how to automatically create Maildir

2015-04-30 Thread Алексей Доморадов

On Thu, 30 Apr 2015 12:12:33 +0300
Алексей Доморадов  alex_...@mail.ru  wrote:

 But it's very uncomfortable to create maildir for each
 user manually. Are there any workaround?
 
set home_mailbox to Maildir/, and create Maildir/{cur,new,tmp}
at directory /etc/skel/, so on next adduser/useradd it will be
automatically create the correct requirement for maildir style inbox.

from main.cf:

# DELIVERY TO MAILBOX
#
# The home_mailbox parameter specifies the optional pathname of a
# mailbox file relative to a user's home directory. The default
# mailbox file is /var/spool/mail/user or /var/mail/user.  Specify
# Maildir/ for qmail-style delivery (the / is required).
#
#home_mailbox = Mailbox
#home_mailbox = Maildir/
If I correctly understood - path specified in the home_mailbox would be 
relative to a user's home directory. So with home_mailbox = Maildir/ all new 
emails would be stored in the /home/webmaster/Maildir/new. And that is not what 
I want. 


Re[2]: local transport: how to automatically create Maildir

2015-04-30 Thread Алексей Доморадов

Четверг, 30 апреля 2015, 21:53 +07:00 от Koko Wijatmoko k...@wijatmoko.name:
On Thu, 30 Apr 2015 16:53:30 +0300
Алексей Доморадов  alex_...@mail.ru  wrote:

 If I correctly understood - path specified in the
 home_mailbox would be relative to a user's home
 directory. So with home_mailbox = Maildir/ all new
 emails would be stored in the /home/webmaster/Maildir/
 new. And that is not what I want.

you need a script for that purpose. from adduser manpage:

---start---
If the file /usr/local/sbin/adduser.local exists, it will be executed
after the user account has been set up in order to do any local setup.
The arguments passed to adduser.local are:
username uid gid home-directory
---end---
Are we reading the same man page? :) I don't see any notes about adduser.local 
in man useradd on CentOS 6


Re: local transport: how to automatically create Maildir

2015-04-30 Thread Koko Wijatmoko
On Thu, 30 Apr 2015 18:14:08 +0300
Алексей Доморадов alex_...@mail.ru wrote:

 Are we reading the same man page? :) I don't see any
 notes about adduser.local in man useradd on CentOS 6

do your home work first, try it... if not work then upgrade your
adduser package rpm from centos 7 or latest tarball.

i'm closed this thread, not postfix issue.


Re[2]: local transport: how to automatically create Maildir

2015-04-30 Thread Алексей Доморадов

On Thu, 30 Apr 2015 18:14:08 +0300
Алексей Доморадов  alex_...@mail.ru  wrote:

 Are we reading the same man page? :) I don't see any
 notes about adduser.local in man useradd on CentOS 6

do your home work first, try it... if not work then upgrade your
adduser package rpm from centos 7 or latest tarball.

i'm closed this thread, not postfix issue.
 do your home work first, try it...
as I told before I need separate home dir and mail spool dir, for e.g.

home - /home/webmaster
mail spool - /var/spool/mail/webmaster/


 if not work then upgrade your adduser package rpm from centos 7 or latest 
 tarball.
OMG, thanks but that's not a solution at all


Re: local transport: how to automatically create Maildir

2015-04-30 Thread Koko Wijatmoko
On Thu, 30 Apr 2015 16:53:30 +0300
Алексей Доморадов alex_...@mail.ru wrote:

 If I correctly understood - path specified in the
 home_mailbox would be relative to a user's home
 directory. So with home_mailbox = Maildir/ all new
 emails would be stored in the /home/webmaster/Maildir/
 new. And that is not what I want.

you need a script for that purpose. from adduser manpage:

---start---
If the file /usr/local/sbin/adduser.local exists, it will be executed
after the user account has been set up in order to do any local setup.
The arguments passed to adduser.local are:
username uid gid home-directory
---end---


Re: local transport: how to automatically create Maildir

2015-04-30 Thread Michael Tokarev
30.04.2015 14:21, Koko Wijatmoko wrote:
 On Thu, 30 Apr 2015 12:12:33 +0300
 Алексей Доморадов alex_...@mail.ru wrote:
 
 But it's very uncomfortable to create maildir for each
 user manually. Are there any workaround?

Postfix do create missing Maildirs by default,
there's no need to do extra work in this context.

But it does that with permissions of the user.
So if the user does not have permissions to create
his own maildir, postfix will not try to do that.
One possible solution is to add all users to the
same group and let this group to write the common
spool directory.  This is bad because this way your
users will be able to create any file in there with
any name.

This is why adduser/useradd etc all have option to
create user's home directory, once when you create
a user, and run this command as root.  Later on,
postfix is able to create missing maildir in there,
with the permissions of that user.

So the solution is might be to move maildir to the
home directory, or, as Koko Wijatmoko suggested,
to run a script when you create a user, a script
which will create user's maildir in an alternative
location.

Or run whole email system as a separate user, such
as vmail, who owns all mailboxes, and who obviously
can create maildirs in its own spool.

Thanks,

/mjt