Current time: 11-15-2024, 07:09 AM Hello There, Guest! (LoginRegister)


Post Reply 
Mail Quota with Dovecot (User + Domain)
Author Message
kouga Offline
Junior Member
*

Posts: 22
Joined: May 2009
Reputation: 0
Post: #1
Mail Quota with Dovecot (User + Domain)
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?
01-25-2010 06:20 PM
Find all posts by this user Quote this message in a reply
TheCry Away
Member
***

Posts: 851
Joined: Oct 2008
Reputation: 21
Post: #2
RE: Mail Quota with Dovecot (User + Domain)
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.
01-25-2010 06:35 PM
Find all posts by this user Quote this message in a reply
aseques Offline
Member
*****
Dev Team

Posts: 330
Joined: May 2008
Reputation: 4
Post: #3
RE: Mail Quota with Dovecot (User + Domain)
(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?
01-25-2010 07:01 PM
Find all posts by this user Quote this message in a reply
kouga Offline
Junior Member
*

Posts: 22
Joined: May 2009
Reputation: 0
Post: #4
RE: Mail Quota with Dovecot (User + Domain)
(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
}
(This post was last modified: 01-25-2010 08:03 PM by kouga.)
01-25-2010 07:01 PM
Find all posts by this user Quote this message in a reply
aseques Offline
Member
*****
Dev Team

Posts: 330
Joined: May 2008
Reputation: 4
Post: #5
RE: Mail Quota with Dovecot (User + Domain)
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...
01-25-2010 07:12 PM
Find all posts by this user Quote this message in a reply
TheCry Away
Member
***

Posts: 851
Joined: Oct 2008
Reputation: 21
Post: #6
RE: Mail Quota with Dovecot (User + Domain)
(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!
(This post was last modified: 01-25-2010 07:20 PM by TheCry.)
01-25-2010 07:13 PM
Find all posts by this user Quote this message in a reply
kouga Offline
Junior Member
*

Posts: 22
Joined: May 2009
Reputation: 0
Post: #7
RE: Mail Quota with Dovecot (User + Domain)
(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
01-25-2010 07:23 PM
Find all posts by this user Quote this message in a reply
TheCry Away
Member
***

Posts: 851
Joined: Oct 2008
Reputation: 21
Post: #8
RE: Mail Quota with Dovecot (User + Domain)
I'm using the same version..
So your config for the quota is ok!
01-25-2010 07:27 PM
Find all posts by this user Quote this message in a reply
kouga Offline
Junior Member
*

Posts: 22
Joined: May 2009
Reputation: 0
Post: #9
RE: Mail Quota with Dovecot (User + Domain)
(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?
01-25-2010 07:30 PM
Find all posts by this user Quote this message in a reply
TheCry Away
Member
***

Posts: 851
Joined: Oct 2008
Reputation: 21
Post: #10
RE: Mail Quota with Dovecot (User + Domain)
(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}
01-25-2010 07:50 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 7 Guest(s)