[Dovecot] Postfixadmin/MySQL/Dovecot 2 and quota

2013-09-08 Thread Matt
Hi all,

I'm setting up a new email server based on the softwares list below:

  * Postfix
  * Dovecot 2.0.9
  * MySQL
  * Postfixadmin 2.3.6

My current problem is I'm unsure whether quota feature is well
configured or not.
In order to test and validate, I use Roundcubemail GUI which provides
percentage of the space used by the mailbox (quota should be applied per
mailbox).

Here, my dovecot configuration:
dovecot.conf:
dict {
  quotadict = mysql:/etc/dovecot/dovecot-dict-quota.conf
}

dovecot-dict-quota.conf:
connect = host=localhost dbname=postfix user=postfix password=postfix
map {
pattern = priv/quota/storage
table = quota2
username_field = username
value_field = bytes
}
map {
pattern = priv/quota/messages
table = quota2
username_field = username
value_field = messages
}

dovecot-sql.conf.ext:
driver = mysql
connect = host=localhost dbname=postfix user=postfix password=postfix
default_pass_scheme = PLAIN-MD5
password_query = SELECT username AS user, password, \
CONCAT('*:storage=', CAST(quota AS CHAR), 'b') AS quota_rule \
FROM mailbox WHERE username = '%u' AND active='1'
user_query = SELECT maildir, 89 AS uid, 12 AS gid, \
concat('dict:storage=',floor(quota/1000),'::proxy::quotadict') AS
quota, \
CONCAT('*:storage=', CAST(quota AS CHAR), 'b') AS quota_rule \
FROM mailbox WHERE username = '%u' AND active='1'

conf.d/90-quota.conf:
plugin {
  quota = dict:user::proxy::quotadict
  quota_rule2 = Trash:storage=+10%%
}

conf.d/20-imap.conf:
protocol imap {
  mail_plugins = $mail_plugins imap_quota
}

When I check postfixadmin GUI, I can see that quota in realtime in
quota2 table, no problem.

But Roundcubemail cannot get this information and shows a unknown quota.
If I add this line:
  quota_rule = *:storage=1G
in conf.d/90-quota.conf file, it works, I mean roundcubemail gets and
shows information (but not the one stored in db of course).

I think I'm close to the right configuration but I need your help to
complete this setup.

Thank you in advance for your help.

Best,
Matt



Re: [Dovecot] Postfixadmin/MySQL/Dovecot 2 and quota

2013-09-08 Thread Daniel Parthey
Hi Matt,

sounds like the quota is correctly updated in MySQL, but your roundcube isn't 
able to fetch quota information via IMAP.

Can you reproduce this via telnet or another IMAP client (e.g. Thunderbird with 
Quota Display Extension)?

Can you be so kind and post your whole dovecot config (doveconf -n)?

Are there any error messages in your dovecot logs regarding quota?

I think that quota_rule, quota_rule2, quota_rule3 etc. are applied in sequence, 
so if you only need one quota_rule, then it should be named quota_rule.

Regards
Daniel



Matt dove...@mygaia.org schrieb:
Hi all,

I'm setting up a new email server based on the softwares list below:

  * Postfix
  * Dovecot 2.0.9
  * MySQL
  * Postfixadmin 2.3.6

My current problem is I'm unsure whether quota feature is well
configured or not.
In order to test and validate, I use Roundcubemail GUI which provides
percentage of the space used by the mailbox (quota should be applied
per
mailbox).

Here, my dovecot configuration:
dovecot.conf:
dict {
  quotadict = mysql:/etc/dovecot/dovecot-dict-quota.conf
}

dovecot-dict-quota.conf:
connect = host=localhost dbname=postfix user=postfix password=postfix
map {
pattern = priv/quota/storage
table = quota2
username_field = username
value_field = bytes
}
map {
pattern = priv/quota/messages
table = quota2
username_field = username
value_field = messages
}

dovecot-sql.conf.ext:
driver = mysql
connect = host=localhost dbname=postfix user=postfix password=postfix
default_pass_scheme = PLAIN-MD5
password_query = SELECT username AS user, password, \
CONCAT('*:storage=', CAST(quota AS CHAR), 'b') AS quota_rule \
FROM mailbox WHERE username = '%u' AND active='1'
user_query = SELECT maildir, 89 AS uid, 12 AS gid, \
concat('dict:storage=',floor(quota/1000),'::proxy::quotadict') AS
quota, \
CONCAT('*:storage=', CAST(quota AS CHAR), 'b') AS quota_rule \
FROM mailbox WHERE username = '%u' AND active='1'

conf.d/90-quota.conf:
plugin {
  quota = dict:user::proxy::quotadict
  quota_rule2 = Trash:storage=+10%%
}

conf.d/20-imap.conf:
protocol imap {
  mail_plugins = $mail_plugins imap_quota
}

When I check postfixadmin GUI, I can see that quota in realtime in
quota2 table, no problem.

But Roundcubemail cannot get this information and shows a unknown
quota.
If I add this line:
  quota_rule = *:storage=1G
in conf.d/90-quota.conf file, it works, I mean roundcubemail gets and
shows information (but not the one stored in db of course).

I think I'm close to the right configuration but I need your help to
complete this setup.

Thank you in advance for your help.

Best,
Matt


Re: [Dovecot] Postfixadmin/MySQL/Dovecot 2 and quota

2013-09-08 Thread Daniel Parthey
Hi Matt,

I forgot to mention that if you're using userdb prefetch, then you might need 
to use userdb_quota_rule instead of quota_rule in your user_query.

Please have a look at the docs:
http://wiki2.dovecot.org/Quota/Configuration

Regards
Daniel

Re: [Dovecot] Postfixadmin/MySQL/Dovecot 2 and quota

2013-09-08 Thread Matt
Hi Daniel,

Thanks for your quick feedback.

I've installed the Quota Display Extension in my Thunderbird (thanks for
the plugin) and the progress bar remains desperately empty but it works
with my Gmail account.

Sorry, I forgot the send my docevot -n previously:
# 2.0.9: /etc/dovecot/dovecot.conf
# OS: Linux 2.6.32-358.el6.x86_64 x86_64 CentOS release 6.4 (Final) ext4
auth_debug = yes
auth_mechanisms = plain login
auth_verbose = yes
dict {
  quotadict = mysql:/etc/dovecot/dovecot-dict-quota.conf
}
mail_debug = yes
mail_location = maildir:/var/mail/vmail/%d/%n
mail_plugins =  quota
mail_privileged_group = mail
mbox_write_locks = fcntl
passdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
plugin {
  quota = dict:user::proxy::quotadict
  quota_rule2 = Trash:storage=+10%%
}
postmaster_address = t...@test.com
quota_full_tempfail = yes
service dict {
  unix_listener dict {
group = mail
mode = 0660
user = vmail
  }
}
service imap-login {
  inet_listener imap {
port = 0
  }
}
service pop3-login {
  inet_listener pop3 {
port = 0
  }
}
service quota-warning {
  executable = script /usr/local/bin/quota-warning.sh
  unix_listener quota-warning {
user = vmail
  }
  user = dovecot
}
ssl_cert = /etc/pki/dovecot/certs/dovecot.pem
ssl_key = /etc/pki/dovecot/private/dovecot.pem
userdb {
  args = uid=vmail gid=vmail home=/var/mail/vmail/%d/%n
  driver = static
}
protocol lda {
  mail_plugins =  quota quota
}
protocol imap {
  mail_plugins =  quota imap_quota
}
protocol pop3 {
  mail_plugins =  quota quota
}


And here an extract of the log:
Sep  8 23:22:54 my_server dovecot: auth: Debug: auth client connected
(pid=12146)
Sep  8 23:22:54 my_server dovecot: auth: Debug: client in:
AUTH#0111#011PLAIN#011service=imap#011secured#011lip=::1#011rip=::1#011lport=993#011rport=39055#011resp=hidden
Sep  8 23:22:54 my_server dovecot: auth: Debug: sql(t...@test.com,::1):
query: SELECT username AS user, password, CONCAT('*:storage=',
CAST(quota AS CHAR), 'b') AS quota_rule FROM mailbox WHERE username =
't...@test.com' AND active='1'
Sep  8 23:22:54 my_server dovecot: auth: Debug: client out:
OK#0111#011user=t...@test.com#011quota_rule=*:storage=3072b
Sep  8 23:22:54 my_server dovecot: auth: Debug: master in:
REQUEST#011317980673#01112146#0111#0110725da6b7ab19fc4fac7f0cf54764b18
Sep  8 23:22:54 my_server dovecot: auth: Debug: master out:
USER#011317980673#011t...@test.com#011uid=5000#011gid=5000#011home=/var/mail/vmail/test.com/test
Sep  8 23:22:54 my_server dovecot: imap-login: Login:
user=t...@test.com, method=PLAIN, rip=::1, lip=::1, mpid=12147, TLS
Sep  8 23:22:54 my_server dovecot: imap: Debug: Loading modules from
directory: /usr/lib64/dovecot
Sep  8 23:22:54 my_server dovecot: imap: Debug: Module loaded:
/usr/lib64/dovecot/lib10_quota_plugin.so
Sep  8 23:22:54 my_server dovecot: imap: Debug: Module loaded:
/usr/lib64/dovecot/lib11_imap_quota_plugin.so
Sep  8 23:22:54 my_server dovecot: imap(t...@test.com): Debug: Effective
uid=5000, gid=5000, home=/var/mail/vmail/test.com/test
Sep  8 23:22:54 my_server dovecot: imap(t...@test.com): Debug: Quota
root: name=user backend=dict args=:proxy::quotadict
Sep  8 23:22:54 my_server dovecot: imap(t...@test.com): Debug: dict
quota: user=t...@test.com, uri=proxy::quotadict, noenforcing=0
Sep  8 23:22:54 my_server dovecot: imap(t...@test.com): Debug:
maildir++: root=/var/mail/vmail/test.com/test, index=, control=,
inbox=/var/mail/vmail/test.com/test
Sep  8 23:22:54 my_server dovecot: dict: mysql: Connected to localhost
(postfix)
Sep  8 23:22:54 my_server dovecot: imap(t...@ecritel.cn): Disconnected:
Logged out bytes=70/529
Sep  8 23:22:57 my_server dovecot: auth: Debug: auth client connected
(pid=12150)
Sep  8 23:22:57 my_server dovecot: auth: Debug: client in:
AUTH#0111#011PLAIN#011service=imap#011secured#011lip=::1#011rip=::1#011lport=993#011rport=39056#011resp=hidden
Sep  8 23:22:57 my_server dovecot: auth: Debug: sql(t...@test.com,::1):
query: SELECT username AS user, password, CONCAT('*:storage=',
CAST(quota AS CHAR), 'b') AS quota_rule FROM mailbox WHERE username =
't...@test.com' AND active='1'
Sep  8 23:22:57 my_server dovecot: auth: Debug: client out:
OK#0111#011user=t...@test.com#011quota_rule=*:storage=3072b
Sep  8 23:22:57 my_server dovecot: auth: Debug: master in:
REQUEST#0111253179393#01112150#0111#0117aeb8af5e5292a96188f20b12f455c7c
Sep  8 23:22:57 my_server dovecot: auth: Debug: master out:
USER#0111253179393#011t...@test.com#011uid=5000#011gid=5000#011home=/var/mail/vmail/test.com/test
Sep  8 23:22:57 my_server dovecot: imap-login: Login:
user=t...@test.com, method=PLAIN, rip=::1, lip=::1, mpid=12152, TLS
Sep  8 23:22:57 my_server dovecot: imap: Debug: Loading modules from
directory: /usr/lib64/dovecot
Sep  8 23:22:57 my_server dovecot: imap: Debug: Module loaded:
/usr/lib64/dovecot/lib10_quota_plugin.so
Sep  8 23:22:57 my_server dovecot: imap: Debug: Module loaded:
/usr/lib64/dovecot/lib11_imap_quota_plugin.so
Sep  8 23:22:57 

[Dovecot] best practice to have sent mail folder on dovecot imap server

2013-09-08 Thread Thomas Koch
I've already asked this here:
http://serverfault.com/questions/533940/best-practice-to-have-sent-mail-
folder-on-dovecot-imap-server

Hi,

when I add a mail account to KMail (or most other MUA I suppose) the sent mail 
folder is on the local machine and I don't have my sent mails on other 
machines.

I'd like to have a sent mail folder in IMAP and I thought that there would 
already exist a standard or best practice how to set this up so that the mail 
is only transfered once to the MTA and from the MTA to the IMAP server.

I even thought to remember an RFC related to this problem?

It isn't that simple, is it? I'm using Exim.

Regards, Thomas Koch


Re: [Dovecot] best practice to have sent mail folder on dovecot imap server

2013-09-08 Thread Reindl Harald

Am 08.09.2013 18:04, schrieb Thomas Koch:
 I've already asked this here:
 http://serverfault.com/questions/533940/best-practice-to-have-sent-mail-
 folder-on-dovecot-imap-server
 
 when I add a mail account to KMail (or most other MUA I suppose) the sent 
 mail 
 folder is on the local machine and I don't have my sent mails on other 
 machines.
 
 I'd like to have a sent mail folder in IMAP and I thought that there would 
 already exist a standard or best practice how to set this up so that the mail 
 is only transfered once to the MTA and from the MTA to the IMAP server
 
 I even thought to remember an RFC related to this problem?
 It isn't that simple, is it? I'm using Exim

these days any kown mail client in case of IMAP copies the message after 
successful
sending via APPEND to the sent folder on the IMAP server - if kmail as default 
stores
it only in a local folder file a bug against kmail

hence you can even configure in which IMAP folder sent messages should be 
stored which
is one of the biggest problem because every random client handles this 
different instead
look if there is a Sent folder use it and display the locale name 
unindependet of
the servers name

mix different clients and in case of Apple mail.app and iPhones with different 
patchlevels
and you will see a ton of different named sent-folder until you configure any 
device to use
the same and remove the orphans

the XLIST capability promises to solve this problem but it will take years 
until any relevant
client is supporting this and only god knows how to act in the situtation where 
you still have
5 different sent-folders - so in the real world expect the problem exists the 
next 5 years

http://www.limilabs.com/blog/imap-list-xlist-and-lsub
___

transfer it only once to the MTA and from there to the sent-folder is more
or less impossible - most mail systems deliver messages via LMTP to dovecot
or whatever MDA and in that case have no predictable way to put it in the
sent folder serverside, at least not if you keep in mind that people
access their mail with different clients at the same time in days
of smartphones, tablets and whatever clients acess the same account
at the same time




signature.asc
Description: OpenPGP digital signature


Re: [Dovecot] best practice to have sent mail folder on dovecot imap server

2013-09-08 Thread Robert Schetterer
Am 08.09.2013 18:15, schrieb Reindl Harald:
 
 Am 08.09.2013 18:04, schrieb Thomas Koch:
 I've already asked this here:
 http://serverfault.com/questions/533940/best-practice-to-have-sent-mail-
 folder-on-dovecot-imap-server


you may use special-use RFC 6154

http://tools.ietf.org/html/rfc6154

have a look

http://www.imapwiki.org/ImapRFCList
http://www.imapwiki.org/SpecialUse

also only german

http://sys4.de/de/blog/2013/03/25/outlook-2013-special-use-mit-dovecot/

some more info

http://dovecot.org/list/dovecot/2011-December/062327.html

so you might be happy with Outlook 2013, K9 Mail new Horde webmail
versions, for thunderbird

http://wiki2.dovecot.org/Plugins/Autocreate might help too

dont know the status of kmail

older blog

https://blog.flameeyes.eu/2013/03/i-ll-stick-with-thunderbird-still

..
Third problem — KMail does not implement the Special Folder extension
defined in RFC 6154
...



 when I add a mail account to KMail (or most other MUA I suppose) the sent 
 mail 
 folder is on the local machine and I don't have my sent mails on other 
 machines.

 I'd like to have a sent mail folder in IMAP and I thought that there would 
 already exist a standard or best practice how to set this up so that the 
 mail 
 is only transfered once to the MTA and from the MTA to the IMAP server

 I even thought to remember an RFC related to this problem?
 It isn't that simple, is it? I'm using Exim
 
 these days any kown mail client in case of IMAP copies the message after 
 successful
 sending via APPEND to the sent folder on the IMAP server - if kmail as 
 default stores
 it only in a local folder file a bug against kmail
 
 hence you can even configure in which IMAP folder sent messages should be 
 stored which
 is one of the biggest problem because every random client handles this 
 different instead
 look if there is a Sent folder use it and display the locale name 
 unindependet of
 the servers name
 
 mix different clients and in case of Apple mail.app and iPhones with 
 different patchlevels
 and you will see a ton of different named sent-folder until you configure any 
 device to use
 the same and remove the orphans

yes i recent saw  equal stuff at a migration from another namespace
really bad behave by apple clients, but there should be no problems with
brand new installs and mailboxes , which means no problem was reported
to me yet


 
 the XLIST capability promises to solve this problem but it will take years 
 until any relevant
 client is supporting this and only god knows how to act in the situtation 
 where you still have
 5 different sent-folders - so in the real world expect the problem exists the 
 next 5 years
 
 http://www.limilabs.com/blog/imap-list-xlist-and-lsub
 ___
 
 transfer it only once to the MTA and from there to the sent-folder is more
 or less impossible - most mail systems deliver messages via LMTP to dovecot
 or whatever MDA and in that case have no predictable way to put it in the
 sent folder serverside, at least not if you keep in mind that people
 access their mail with different clients at the same time in days
 of smartphones, tablets and whatever clients acess the same account
 at the same time
 
 



Best Regards
MfG Robert Schetterer

-- 
[*] sys4 AG

http://sys4.de, +49 (89) 30 90 46 64
Franziskanerstraße 15, 81669 München

Sitz der Gesellschaft: München, Amtsgericht München: HRB 199263
Vorstand: Patrick Ben Koetter, Axel von der Ohe, Marc Schiffbauer
Aufsichtsratsvorsitzender: Florian Kirstein


Re: [Dovecot] Postfixadmin/MySQL/Dovecot 2 and quota

2013-09-08 Thread Daniel Parthey

Hi Matt

Am 08.09.2013 17:32, schrieb Matt:

I've installed the Quota Display Extension in my Thunderbird (thanks for
the plugin) and the progress bar remains desperately empty but it works
with my Gmail account.


This is exactly what was expected.
Dovecot userdb doesn't know about your user specific quota_rule.


userdb {
   args = uid=vmail gid=vmail home=/var/mail/vmail/%d/%n
   driver = static
}


Dynamic extra fields like userdb_quota_rule from SQL would not
work with a static userdb, since static db is only able to return
static extra fields.

You will need to use userdb driver = sql to fetch quota_rule from SQL.

If it works, the following command should show the user's quota rule:
doveadm user t...@test.com

Regards
Daniel


[Dovecot] Is this odd?

2013-09-08 Thread LuKreme
 $ doveadm user kremels
field   value
uid 1033
gid 1033
home/home/kremels
mailmaildir:~/Maildir
system_groups_user  kreme

 $ doveadm user u...@virtual.example.com
field   value
uid 89
gid 89
home/usr/local/virtual/u...@virtual.example.com/
mail/usr/local/virtual/u...@virtual.example.com
mail_location   /usr/local/virtual/u...@virtual.example.com

The local users doesn't have a mail_location set at all, and has a very 
different mail definition. This seem to be a side-effect of the fact that the 
home of the virtual user is the top level maildir, but should I set mail to 
maildir:~ ??

-- 
Where there is a party, everyone is there
Everyone will leave at exactly the same time
When this party is over it will start again
But not been any different be exactly the same



Re: [Dovecot] More fine-grained connection limitations?

2013-09-08 Thread Joseph Tam



There is the mail_max_userip_connections setting, which helps for
dealing with number of connections at any given time, but I'm looking
for something that will help deal with users who configure their mail
clients to connect too frequently.

...

It would be really great if there were a way to tarpit those users to
slow them down, or send them an imap message saying they are connecting
to often and connections have been disabled for the next 5 minutes or
something.


There might be an unintended consequence: I see connection spikes when
users try to do a global string search across mailboxes.

Joseph Tam jtam.h...@gmail.com