Re: Quota for mail

2011-11-09 Thread Egoitz Aurrekoetxea Aurre



On Wed, 9 Nov 2011, Martin Strand wrote:B


For what it's worth, here's a similar policy daemon that I've been using for 
a few years.
- it only checks the quota if MAIL FROM has a SIZE parameter (which is not 
always the case)
- it executes 'postmap' on each request to find the proper maildir so will 
not scale very well
- been using it on an ancient Postfix installation together with the VDA 
patch and Courier
- daemon must be run by a user with access to all maildirs (in my case it's 
'vmail')





Martin, take a look at Postfix Quota Reject 
(http://postfixquotareject.ramattack.net). It scales well and it's 
designed having in mind isp with front mailscanning machines... although 
works nice too on little (or single machine) environments.


Bye!




Re: Quota for mail

2011-11-09 Thread Egoitz Aurrekoetxea Aurre



On Tue, 8 Nov 2011, Stan Hoeppner wrote:


Apologies everyone.  I got my threads confused.  I thought I was
replying to the reject or discard outgoing mail thread.  (palm to
forehead)  This thread has nothing to do with spambots.


No problem ;)




--
Stan




Re: Quota for mail

2011-11-08 Thread Egoitz Aurrekoetxea Aurre



On Mon, 7 Nov 2011, Leslie León Sinclair wrote:

Thanks again, and sorry the thread, I´am stacked here. Almost near the 
solution.


Best regards.








You could too take a look to Postfix Quota Reject. 
http://postfixquotareject.ramattack.net. It's a postfix policy daemon 
which allow mail to be rejected at smtp dialogue when mailbox are 
overquota... can work from the own mailbox machine or from the own 
mailscanning machine farm asking to a daemon in mailbox machines.


If you've some doubt... here I am...

Re: Quota for mail

2011-11-08 Thread Stan Hoeppner
On 11/8/2011 3:30 AM, Egoitz Aurrekoetxea Aurre wrote:

 On Mon, 7 Nov 2011, Leslie León Sinclair wrote:
 
 Thanks again, and sorry the thread, I´am stacked here. Almost near the
 solution.

 You could too take a look to Postfix Quota Reject.
 http://postfixquotareject.ramattack.net. It's a postfix policy daemon
 which allow mail to be rejected at smtp dialogue when mailbox are
 overquota... can work from the own mailbox machine or from the own
 mailscanning machine farm asking to a daemon in mailbox machines.

His problem is spambots relaying *outbound* through Postfix.  This isn't
an inbound problem.  You're describing an inbound policy.

-- 
Stan



Re: Quota for mail

2011-11-08 Thread Wietse Venema
Stan Hoeppner:
 His problem is spambots relaying *outbound* through Postfix.  This isn't
 an inbound problem.  You're describing an inbound policy.

In that case, any policy daemon that counts the messages or bytes
per client or sender will do the job. There are rate limits in
policyd and postfwd, for example.

Wietse


Re: Quota for mail

2011-11-08 Thread Leslie León Sinclair
The problem is showing the quota for the users[I have multiple quotas, a 
field of a MySQL table], Users1 have 10MB quota and Users2 have 100MB, 
some users have 250MB, how can I show quota with a query, with Dovecot 
or Postfix??? If all my users have the same quota, works for me great[I 
have tested], but different quota here... That´s the thing... Still 
working on that... If someone have solved the same issue please share 
the piece of code, or script :D.


Thanks for replies...

--
/***
*Leslie León Sinclair
*Administrador de Redes
*Facultad de Ingenieria Electrica, CUJAE.
*Calle 114 #11901 e/ Ciclovía y Rotonda
*Marianao 19390, Ciudad de la Habana, Cuba
*Tel: (53 7) 266-3321
*Miembro de GUTL -  
http://www.ecured.cu/index.php/Grupo_de_Usuarios_de_Tecnolog%C3%ADas_Libres_GUTL
*Another happy Slackware  Debian GNU/Linux user
*Proud GNU/Linux User #445535 -  http://counter.li.org/
*Katana yanai, otoko nanda.
/




Participe en Universidad 2012, del 13 al 17 de febrero de 2012.
Habana, Cuba: http://www.congresouniversidad.cu
Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu

Participe en el Segundo Congreso Medio Ambiente Construido y 
Desarrollo Sustentable (MACDES 2011) del 6 al 9 de diciembre de 2011, 
Hotel Nacional, Habana, Cuba: http://macdes.cujae.edu.cu


Re: Quota for mail

2011-11-08 Thread Wietse Venema
Leslie Le?n Sinclair:
 The problem is showing the quota for the users[I have multiple quotas, a 
 field of a MySQL table], Users1 have 10MB quota and Users2 have 100MB, 
 some users have 250MB, how can I show quota with a query, with Dovecot 
 or Postfix??? If all my users have the same quota, works for me great[I 
 have tested], but different quota here... That?s the thing... Still 
 working on that... If someone have solved the same issue please share 
 the piece of code, or script :D.

policyd supports MySQL queries, and its website supports RTFM.

Wietse


Re: Quota for mail

2011-11-08 Thread Tobias Hachmer

Am 08.11.2011 15:18, schrieb Leslie León Sinclair:

The problem is showing the quota for the users[I have multiple
quotas, a field of a MySQL table], Users1 have 10MB quota and Users2
have 100MB, some users have 250MB, how can I show quota with a query,
with Dovecot or Postfix??? If all my users have the same quota, works
for me great[I have tested], but different quota here... That´s the
thing... Still working on that... If someone have solved the same
issue please share the piece of code, or script :D.


You need the correct dovecot configuration, especially the correct 
quota config and user_query.


I've seen in your earlier posts you use ...AS quota... in your 
user_query. I think you need there ...AS quota_rule...!


For further information/ support please contact dovecot mailing list or 
the links below:


- /usr/share/doc/postfixadmin/DOCUMENTS/DOVECOT.txt.gz (path in debian 
squeeze)

- http://wiki1.dovecot.org/Quota/Dict (for Dovecot v1)
- http://wiki2.dovecot.org/Quota/Dict (for Dovecot v2)

Regards, Tobias




[SOLVED]Re: Quota for mail

2011-11-08 Thread Leslie León Sinclair

Done, at last!!!

Missing stuff on my install:

[PostfixAdmin config file]
$CONF['used_quotas'] = 'YES'; // Was no activated, this was the main 
reason of my past mails. Sorry again.

$CONF['quota'] = 'YES';

Other changes made:

[Dovecot config file]
protocol imap {
mail_plugins = quota imap_quota
}

protocol pop3 {
mail_plugins = quota
}

protocol lda {
mail_plugins = quota
}

dict {
quota = mysql:/etc/dovecot/dovecot-quota.conf
}

plugin {
quota = dict:storage=20 proxy::quota
}

[dovecot-quota.conf]
driver = mysql
connect = host=localhost dbname=postfix user=postfix password=yourpassword
default_pass_scheme = MD5-CRYPT
table = quota
select_field = current
where_field = path
username_field = username

[dovecot-sql.conf]
password_query = SELECT username AS user,password FROM mailbox WHERE 
username = '%u'
user_query = SELECT maildir, 5000 AS uid, 5000 AS gid, 
CONCAT('dict:storage=',floor(quota/1024),' proxy::quota') as quota FROM 
mailbox WHERE username = '%u'


Best regards and many, many thanks to all.
HTH all trying to do the same, the way I did it.


--
/***
*Leslie León Sinclair
*Administrador de Redes
*Facultad de Ingenieria Electrica, CUJAE.
*Calle 114 #11901 e/ Ciclovía y Rotonda
*Marianao 19390, Ciudad de la Habana, Cuba
*Tel: (53 7) 266-3321
*Miembro de GUTL -  
http://www.ecured.cu/index.php/Grupo_de_Usuarios_de_Tecnolog%C3%ADas_Libres_GUTL
*Another happy Slackware  Debian GNU/Linux user
*Proud GNU/Linux User #445535 -  http://counter.li.org/
*Katana yanai, otoko nanda.
/




Participe en Universidad 2012, del 13 al 17 de febrero de 2012.
Habana, Cuba: http://www.congresouniversidad.cu
Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu

Participe en el Segundo Congreso Medio Ambiente Construido y 
Desarrollo Sustentable (MACDES 2011) del 6 al 9 de diciembre de 2011, 
Hotel Nacional, Habana, Cuba: http://macdes.cujae.edu.cu


Re: [SOLVED]Re: Quota for mail

2011-11-08 Thread Tobias Hachmer

Am 08.11.2011 18:16, schrieb Leslie León Sinclair:

Done, at last!!!

Missing stuff on my install:

[PostfixAdmin config file]
$CONF['used_quotas'] = 'YES'; // Was no activated, this was the main
reason of my past mails. Sorry again.
$CONF['quota'] = 'YES';


Don't forget:

[PostfixAdmin config file]
// if you use dovecot = 1.2, set this to yes.
// Note about dovecot config: table quota is for 1.0  1.1, table 
quota2 is for dovecot 1.2 and newer

$CONF['new_quota_table'] = 'YES';

Regards, Tobias


Re: Quota for mail

2011-11-08 Thread Egoitz Aurrekoetxea Aurre



On Tue, 8 Nov 2011, Stan Hoeppner wrote:


http://postfixquotareject.ramattack.net. It's a postfix policy daemon
which allow mail to be rejected at smtp dialogue when mailbox are
overquota... can work from the own mailbox machine or from the own
mailscanning machine farm asking to a daemon in mailbox machines.


His problem is spambots relaying *outbound* through Postfix.  This isn't
an inbound problem.  You're describing an inbound policy.


I have read it pretty fast, but I would say he was talking about 
enforcing quota for mailboxes in Postfix and here Postfix Quota Reject 
does the trick pretty nice even in ISP environments.


Bye!!





--
Stan




Re: Quota for mail

2011-11-08 Thread Egoitz Aurrekoetxea Aurre



On Tue, 8 Nov 2011, Egoitz Aurrekoetxea Aurre wrote:




On Tue, 8 Nov 2011, Stan Hoeppner wrote:


http://postfixquotareject.ramattack.net. It's a postfix policy daemon
which allow mail to be rejected at smtp dialogue when mailbox are
overquota... can work from the own mailbox machine or from the own
mailscanning machine farm asking to a daemon in mailbox machines.


His problem is spambots relaying *outbound* through Postfix.  This isn't
an inbound problem.  You're describing an inbound policy.






else why is he talking about mda, lmtp and so...??... they have nothing to 
do for calculating outbound sending quotas








--
Stan






Re: Quota for mail

2011-11-08 Thread Stan Hoeppner
On 11/8/2011 6:48 AM, Wietse Venema wrote:
 Stan Hoeppner:
 His problem is spambots relaying *outbound* through Postfix.  This isn't
 an inbound problem.  You're describing an inbound policy.
 
 In that case, any policy daemon that counts the messages or bytes
 per client or sender will do the job. There are rate limits in
 policyd and postfwd, for example.
 
   Wietse


Apologies everyone.  I got my threads confused.  I thought I was
replying to the reject or discard outgoing mail thread.  (palm to
forehead)  This thread has nothing to do with spambots.

-- 
Stan



Re: Quota for mail

2011-11-08 Thread Martin Strand

On Tue, 08 Nov 2011 10:30:47 +0100, Egoitz Aurrekoetxea Aurre 
ego...@ramattack.net wrote:


You could too take a look to Postfix Quota Reject.
http://postfixquotareject.ramattack.net. It's a postfix policy daemon
which allow mail to be rejected at smtp dialogue when mailbox are
overquota... can work from the own mailbox machine or from the own
mailscanning machine farm asking to a daemon in mailbox machines.



For what it's worth, here's a similar policy daemon that I've been using for a 
few years.
- it only checks the quota if MAIL FROM has a SIZE parameter (which is not 
always the case)
- it executes 'postmap' on each request to find the proper maildir so will not 
scale very well
- been using it on an ancient Postfix installation together with the VDA patch 
and Courier
- daemon must be run by a user with access to all maildirs (in my case it's 
'vmail')


Might not be a good idea to paste this in a message since whitespace is 
significant in Python, but here it is:




#!/usr/bin/env python
##
## Maildir++ quota checking policy server for Postfix - http://www.postfix.org/
##
## 1. Uses 'postconf' and 'postmap' to lookup the recipient's maildir
## 2. Reads the quota file (maildirsize) to determine available storage
## 3. Checks the message size against available storage and returns
##- REJECT if there's not enough storage
##- DUNNO  if no message size was specified in 'MAIL FROM'
##- DUNNO  in case of a lookup error. Perhaps this ought to be DEFER 
instead, not sure.
##- WARN   if the recipient does not exist (if postmap returns nothing)
##
##
##
## Logging
## ---
## No logging is done unless the --debug parameter is passed in. With --debug, 
all policy results will be sent to syslog.
## facility = mail
## priority = debug
## ident = postfix/script-name  (Just like Postfix's other daemons)
##
##
##
## Example usage
## -
##
## [master.cf]
## ...
## check-quota unix -  n   n   -   -   spawn user=vmail
## argv=/usr/local/libexec/check-quota
## --debug
## ...
##
## [main.cf]
## ...
## smtpd_recipient_restrictions =
## ...
## check_policy_service unix:private/check-quota
## ...
##
##
##
## Notes
## -
## 1. Proxymap is never used since it's a private service and only the postfix 
user may access it. Any 'proxy:' prefix for maps is removed.
## 2. The user running this policy server must be able to read 'maildirsize' in 
each maildir.
## 3. This policy server only checks storage quotas, not message quotas
##
import optparse
import os.path
import os
import sys
import select
import syslog

class InvalidRecipientError(Exception):
pass

class QuotaChecker:
def __init__(self, timeout):
self.timeout = timeout
self.virtual_mailbox_base = os.popen(/usr/sbin/postconf -h 
virtual_mailbox_base).read().strip()
self.virtual_mailbox_maps = os.popen(/usr/sbin/postconf -h 
virtual_mailbox_maps | sed s/proxy://g).read().strip()

def find_maildir(self, recipient):

# Pass recipient to postmap
postmap = /usr/sbin/postmap -q '%s' '%s' % (recipient, 
self.virtual_mailbox_maps)
input = os.popen(postmap)

# Wait for postmap to finish
rfds, wfds, efds = select.select( [input], [], [], self.timeout)
if not rfds:
input.close()
raise IOError, Lookup timeout for %s % recipient

# Get maildir
maildir = input.read().strip()
exit_code = input.close()
if exit_code == 256:
# Recipient does not exist
return None
if exit_code or not maildir:
raise IOError, Lookup error for %s % recipient

return maildir

def get_available_storage(self, recipient):

# Lookup maildir
maildir = self.find_maildir(recipient)
if not maildir:
raise InvalidRecipientError, No such recipient: %s % 
recipient

# Find quota file
filename = os.path.join(self.virtual_mailbox_base, maildir, 
maildirsize)
if not os.path.exists(filename):
# No quota set
return None

# Read quota file
file = open(filename)
try:
max_storage = 0L
used_storage = 0L
for line in file:
line = line.strip()
try:
(storage, messages) = line.split()
except ValueError:
storage = line

Quota for mail

2011-11-07 Thread Leslie León Sinclair

Hi:

I have a Postfix+MySQL+Dovecot+PostfixAdmin[Lenny server] setup, and 
works very nice. But I need to put quota in my webmail[RoundCube], and 
after a long research in Internet, I see DoveAdm as a good option,the 
issue is...


- It´s DoveAdm a command part of Dovecot, if so, where is it?

- Or a script/package,if so, where can I download it? Because I don´t 
find the download link.


- Another simple way to implement quota in mail. I´m still 
reading/searching several ways to do the same with ease.


Thanks in advance  for your time.
Best regards.

--
/***
*Leslie León Sinclair
*Administrador de Redes
*Facultad de Ingenieria Electrica, CUJAE.
*Calle 114 #11901 e/ Ciclovía y Rotonda
*Marianao 19390, Ciudad de la Habana, Cuba
*Tel: (53 7) 266-3321
*Miembro de GUTL -  
http://www.ecured.cu/index.php/Grupo_de_Usuarios_de_Tecnolog%C3%ADas_Libres_GUTL
*Another happy Slackware  Debian GNU/Linux user
*Proud GNU/Linux User #445535 -  http://counter.li.org/
*Katana yanai, otoko nanda.
/




Participe en Universidad 2012, del 13 al 17 de febrero de 2012.
Habana, Cuba: http://www.congresouniversidad.cu
Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu

Participe en el Segundo Congreso Medio Ambiente Construido y 
Desarrollo Sustentable (MACDES 2011) del 6 al 9 de diciembre de 2011, 
Hotel Nacional, Habana, Cuba: http://macdes.cujae.edu.cu


Re: Quota for mail

2011-11-07 Thread Duane Hill
On Monday, November 07, 2011 at 15:41:38 UTC, les...@electrica.cujae.edu.cu 
confabulated:

 Hi:

 I have a Postfix+MySQL+Dovecot+PostfixAdmin[Lenny server] setup, and 
 works very nice. But I need to put quota in my webmail[RoundCube], and
 after a long research in Internet, I see DoveAdm as a good option,the 
 issue is...

 - It´s DoveAdm a command part of Dovecot, if so, where is it?

 - Or a script/package,if so, where can I download it? Because I don´t 
 find the download link.

 - Another simple way to implement quota in mail. I´m still 
 reading/searching several ways to do the same with ease.

 Thanks in advance  for your time.
 Best regards.

I believe doveadm is a part of Dovecot 2.x.

-- 
Duane Hill



Re: Quota for mail

2011-11-07 Thread Nikolaos Milas

On 7/11/2011 5:41 μμ, Leslie León Sinclair wrote:


But I need to put quota in my webmail


Hi,

Use postfix and dovecot, with lda or lmtp and setup quotas in dovecot.

See: http://www.dovecot.org/list/dovecot/2011-February/057630.html

Hope that helps,
Nick



smime.p7s
Description: S/MIME Cryptographic Signature


Re: Quota for mail

2011-11-07 Thread Robert Schetterer
Am 07.11.2011 15:48, schrieb Duane Hill:
 On Monday, November 07, 2011 at 15:41:38 UTC, les...@electrica.cujae.edu.cu 
 confabulated:
 
 Hi:
 
 I have a Postfix+MySQL+Dovecot+PostfixAdmin[Lenny server] setup, and 
 works very nice. But I need to put quota in my webmail[RoundCube], and
 after a long research in Internet, I see DoveAdm as a good option,the 
 issue is...
 
 - It´s DoveAdm a command part of Dovecot, if so, where is it?
 
 - Or a script/package,if so, where can I download it? Because I don´t 
 find the download link.
 
 - Another simple way to implement quota in mail. I´m still 
 reading/searching several ways to do the same with ease.
 
 Thanks in advance  for your time.
 Best regards.
 
 I believe doveadm is a part of Dovecot 2.x.
 

imap quota can be configured in sql
then configure dovecot imap/lmtp/lda to honor it
and use dovecot/postfix with lmtp/lda

no need for doveadm
look dovecot site for configure examples

-- 
Best Regards

MfG Robert Schetterer

Germany/Munich/Bavaria


Re: Quota for mail

2011-11-07 Thread Leslie León Sinclair
The problem is the query for MySQL... I have quotas in a table in mysql, 
but there´s a lot of parameters that I dont know when to use it.


For example:
1- The quota query in MySQL - query = SELECT quota FROM mailbox WHERE 
username='%s'
2- The quota query in Dovecot - user_query = SELECT home, uid, gid, 
concat('maildir:storage=', quota_kb) AS quota FROM users WHERE userid = '%u'


I´am testing - SELECT quota CONCAT('maildir:storage=', quota_kb) FROM 
mailbox WHERE username='%s', or alternative queries...


If works I will post the answer.

Thanks for the reply :D.

--
/***
*Leslie León Sinclair
*Administrador de Redes
*Facultad de Ingenieria Electrica, CUJAE.
*Calle 114 #11901 e/ Ciclovía y Rotonda
*Marianao 19390, Ciudad de la Habana, Cuba
*Tel: (53 7) 266-3321
*Miembro de GUTL -  
http://www.ecured.cu/index.php/Grupo_de_Usuarios_de_Tecnolog%C3%ADas_Libres_GUTL
*Another happy Slackware  Debian GNU/Linux user
*Proud GNU/Linux User #445535 -  http://counter.li.org/
*Katana yanai, otoko nanda.
/




Participe en Universidad 2012, del 13 al 17 de febrero de 2012.
Habana, Cuba: http://www.congresouniversidad.cu
Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu

Participe en el Segundo Congreso Medio Ambiente Construido y 
Desarrollo Sustentable (MACDES 2011) del 6 al 9 de diciembre de 2011, 
Hotel Nacional, Habana, Cuba: http://macdes.cujae.edu.cu


Re: Quota for mail

2011-11-07 Thread Leslie León Sinclair
The issue is that I have multiple quotas/domains, for my users. Some 
users have 10MB, others have 100MB, and Admin/Root[postmaster, 
webmaster, abuse, hostmaster] have 500MB and I need to fetch the quota, 
for the specific user with MySQL.


Best regards.

--
/***
*Leslie León Sinclair
*Administrador de Redes
*Facultad de Ingenieria Electrica, CUJAE.
*Calle 114 #11901 e/ Ciclovía y Rotonda
*Marianao 19390, Ciudad de la Habana, Cuba
*Tel: (53 7) 266-3321
*Miembro de GUTL -  
http://www.ecured.cu/index.php/Grupo_de_Usuarios_de_Tecnolog%C3%ADas_Libres_GUTL
*Another happy Slackware  Debian GNU/Linux user
*Proud GNU/Linux User #445535 -  http://counter.li.org/
*Katana yanai, otoko nanda.
/




Participe en Universidad 2012, del 13 al 17 de febrero de 2012.
Habana, Cuba: http://www.congresouniversidad.cu
Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu

Participe en el Segundo Congreso Medio Ambiente Construido y 
Desarrollo Sustentable (MACDES 2011) del 6 al 9 de diciembre de 2011, 
Hotel Nacional, Habana, Cuba: http://macdes.cujae.edu.cu


Re: Quota for mail

2011-11-07 Thread Reindl Harald


Am 07.11.2011 18:02, schrieb Leslie León Sinclair:
 The issue is that I have multiple quotas/domains, for my users. Some users 
 have 10MB, others have 100MB, and
 Admin/Root[postmaster, webmaster, abuse, hostmaster] have 500MB and I need to 
 fetch the quota, for the specific
 user with MySQL.

well, give http://www.dbmail.org/ a try
there you have a column for quota in the user-table since a long time



signature.asc
Description: OpenPGP digital signature


Re: Quota for mail

2011-11-07 Thread Duane Hill
On Monday, November 07, 2011 at 17:02:24 UTC, les...@electrica.cujae.edu.cu 
confabulated:

 The issue is that I have multiple quotas/domains, for my users. Some 
 users have 10MB, others have 100MB, and Admin/Root[postmaster, 
 webmaster, abuse, hostmaster] have 500MB and I need to fetch the quota,
 for the specific user with MySQL.

 Best regards.

Have you checked out this page:
  http://wiki1.dovecot.org/Quota/Dict

I used the one similar for v2.x and was able to set up per-user quotas
with MySQL.

You should move this discussion over to the Dovecot mailing list.

-- 
Duane Hill



Re: Quota for mail

2011-11-07 Thread Leslie León Sinclair
Thanks again, and sorry the thread, I´am stacked here. Almost near the 
solution.


Best regards.




You should move this discussion over to the Dovecot mailing list.




--
/***
*Leslie León Sinclair
*Administrador de Redes
*Facultad de Ingenieria Electrica, CUJAE.
*Calle 114 #11901 e/ Ciclovía y Rotonda
*Marianao 19390, Ciudad de la Habana, Cuba
*Tel: (53 7) 266-3321
*Miembro de GUTL -  
http://www.ecured.cu/index.php/Grupo_de_Usuarios_de_Tecnolog%C3%ADas_Libres_GUTL
*Another happy Slackware  Debian GNU/Linux user
*Proud GNU/Linux User #445535 -  http://counter.li.org/
*Katana yanai, otoko nanda.
/




Participe en Universidad 2012, del 13 al 17 de febrero de 2012.
Habana, Cuba: http://www.congresouniversidad.cu
Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu

Participe en el Segundo Congreso Medio Ambiente Construido y 
Desarrollo Sustentable (MACDES 2011) del 6 al 9 de diciembre de 2011, 
Hotel Nacional, Habana, Cuba: http://macdes.cujae.edu.cu