ispCP - Board - Support
Mail Quota with Dovecot (User + Domain) - Printable Version

+- ispCP - Board - Support (http://www.isp-control.net/forum)
+-- Forum: ispCP Omega Support Area (/forum-30.html)
+--- Forum: System Setup & Installation (/forum-32.html)
+--- Thread: Mail Quota with Dovecot (User + Domain) (/thread-9361.html)

Pages: 1 2 3


Mail Quota with Dovecot (User + Domain) - kouga - 01-25-2010 06:20 PM

Hi all,

I'm enabling mail quota per user by sending mail through Dovecot LDA.
Each user's mail quota DOES work, but domain quota isn't calculated while mails are sent to user's mailbox.

For example, an environment like below.
User quota = 500 MB (set by mistake)
Domain quota = 100 MB

When more than 100MB of diskspace is used,
uploading files through FTP connection will be disabled.
But mails will still be sent to users unless it uses 500MB.

My question:
Is there a way to enable BOTH user and domain quota when receiving mails through Dovecot?


RE: Mail Quota with Dovecot (User + Domain) - TheCry - 01-25-2010 06:35 PM

Please post the Line from Dovecot, which you are using to calculate the the quota...
I postet some month ago, another user query for dovecot because the query from the wiki doesn't work correctly!
But no one gives a reply to it, so i don't want to change the wiki.


RE: Mail Quota with Dovecot (User + Domain) - aseques - 01-25-2010 07:01 PM

(01-25-2010 06:35 PM)TheCry Wrote:  Please post the Line from Dovecot, which you are using to calculate the the quota...
I postet some month ago, another user query for dovecot because the query from the wiki doesn't work correctly!
But no one gives a reply to it, so i don't want to change the wiki.
Hello, I am the mantainer for the wiki page, and I am looking at the forum quite often. If you have any problem with dovecot I'd recommend you to post to this thread:
http://www.isp-control.net/forum/thread-6088.html
I am subscribed to it, so I get mailed of the answers.

BTW: What's the problem with the sql query?


RE: Mail Quota with Dovecot (User + Domain) - kouga - 01-25-2010 07:01 PM

(01-25-2010 06:35 PM)TheCry Wrote:  Please post the Line from Dovecot, which you are using to calculate the the quota...

I hope this is what you're looking for....

/etc/dovecot/dovecot-sql-domain.conf
Code:
driver = mysql
connect = host=localhost dbname=ispcp user=ispcp_dovecot password=MASKED
user_query = SELECT concat('/var/mail/virtual/', domain.domain_name, '/',mail_acc) as home, '3001' as uid, '12' as gid, concat('*:storage=', floor(quota/1024)) AS quota_rule FROM mail_users inner join domain on mail_users.domain_id = domain.domain_id WHERE mail_acc='%n' and (mail_type='normal_mail' OR mail_type='normal_mail,normal_forward');
I'm on CentOS 5.2 so the uid and gid for vmail might be different on your OS.


/etc/dovecot.conf
Code:
- partial -

}
userdb sql {
  args = /etc/dovecot/dovecot-sql-domain.conf
}
plugin {
quota = maildir:User quota
quota_rule = *:storage=10M
}



RE: Mail Quota with Dovecot (User + Domain) - aseques - 01-25-2010 07:12 PM

This is the first time I see the quota_rule stuff, I am still using the 1.0 behaviour of
('maildir:storage=', floor(quota/1024)) AS quota
instead of your
('*:storage=', floor(quota/1024)) AS quota_rule

I'll have a look at that, with the previous behavior, it was impossible to have a per domain quota.
Will see with the post 1.1 version...


RE: Mail Quota with Dovecot (User + Domain) - TheCry - 01-25-2010 07:13 PM

(01-25-2010 07:01 PM)kouga Wrote:  I hope this is what you're looking for....
Yes.. It's right

Code:
user_query = SELECT concat('/var/mail/virtual/', domain.domain_name, '/',mail_acc) as home, '3001' as uid, '12' as gid, concat('*:storage=', floor(quota/1024)) AS quota_rule FROM mail_users inner join domain on mail_users.domain_id = domain.domain_id WHERE mail_acc='%n' and (mail_type='normal_mail' OR mail_type='normal_mail,normal_forward');

In my opinion is this not correct, because %n ist the wrong variable.
%n means
Quote:user part in user@domain, same as %u if there's no domain
If you have different emailadresses eg "info@..." you will get more than one line in this query.

I use this query
Code:
user_query = SELECT concat('/var/mail/virtual/', domain.domain_name, '/',mail_acc) as home, '1000' as uid, '8' as gid, concat('*:bytes=', quota) AS quota_rule FROM mail_users inner join domain on mail_users.domain_id = domain.domain_id WHERE mail_addr='%u' and (mail_type='normal_mail' OR mail_type='normal_mail,normal_forward');

More info about dovecot variables: http://wiki.dovecot.org/Variables

Btw...
Code:
as home, '3001' as uid, '12'
Is this correct on your system?
This are the uid and gid of the user vmail!
Please check this in your passwd!


RE: Mail Quota with Dovecot (User + Domain) - kouga - 01-25-2010 07:23 PM

(01-25-2010 07:12 PM)aseques Wrote:  This is the first time I see the quota_rule stuff, I am still using the 1.0 behaviour of
('maildir:storage=', floor(quota/1024)) AS quota
instead of your
('*:storage=', floor(quota/1024)) AS quota_rule

I'll have a look at that, with the previous behavior, it was impossible to have a per domain quota.
Will see with the post 1.1 version...

I'm using Dovecot 1.2.6.

So, it's waste of time figuring out how to have per domain quota for mail...?Sad


RE: Mail Quota with Dovecot (User + Domain) - TheCry - 01-25-2010 07:27 PM

I'm using the same version..
So your config for the quota is ok!


RE: Mail Quota with Dovecot (User + Domain) - kouga - 01-25-2010 07:30 PM

(01-25-2010 07:13 PM)TheCry Wrote:  
Code:
user_query = SELECT concat('/var/mail/virtual/', domain.domain_name, '/',mail_acc) as home, '3001' as uid, '12' as gid, concat('*:storage=', floor(quota/1024)) AS quota_rule FROM mail_users inner join domain on mail_users.domain_id = domain.domain_id WHERE mail_acc='%n' and (mail_type='normal_mail' OR mail_type='normal_mail,normal_forward');

In my opinion is this not correct, because %n ist the wrong variable.
%n means
Quote:user part in user@domain, same as %u if there's no domain
If you have different emailadresses eg "info@..." you will get more than one line in this query.

I see...I'll test this movement.

Quote:I use this query
Code:
user_query = SELECT concat('/var/mail/virtual/', domain.domain_name, '/',mail_acc) as home, '1000' as uid, '8' as gid, concat('*:bytes=', quota) AS quota_rule FROM mail_users inner join domain on mail_users.domain_id = domain.domain_id WHERE mail_addr='%u' and (mail_type='normal_mail' OR mail_type='normal_mail,normal_forward');

More info about dovecot variables: http://wiki.dovecot.org/Variables

Btw...
Code:
as home, '3001' as uid, '12'
Is this correct on your system?
This are the uid and gid of the user vmail!
Please check this in your passwd!

This is my setting in master.cf for postfix(partial).
Code:
dovecot unix - n n - - pipe
  flags=DRhu user=vmail:mail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${recipient} -s
Am I doing something weird here?


RE: Mail Quota with Dovecot (User + Domain) - TheCry - 01-25-2010 07:50 PM

(01-25-2010 07:30 PM)kouga Wrote:  
Code:
as home, '3001' as uid, '12'
Is this correct on your system?
This are the uid and gid of the user vmail!
Please check this in your passwd!
Check this!!! This is important!

(01-25-2010 07:30 PM)kouga Wrote:  This is my setting in master.cf for postfix(partial).
Code:
dovecot unix - n n - - pipe
  flags=DRhu user=vmail:mail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${recipient} -s
Am I doing something weird here?
Check the path of deliver
This is my config
Code:
dovecot unix - n n - - pipe
  flags=DRhu user=vmail:mail argv=/usr/local/libexec/dovecot/deliver -f ${sender} -d ${recipient}