Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1852885
  • 博文数量: 334
  • 博客积分: 11301
  • 博客等级: 上将
  • 技术积分: 3452
  • 用 户 组: 普通用户
  • 注册时间: 2006-10-18 10:19
个人简介

路虽弥,不行不至;事虽少,不做不成。

文章分类

全部博文(334)

文章存档

2013年(4)

2012年(19)

2011年(27)

2010年(71)

2009年(45)

2008年(15)

2007年(84)

2006年(69)

分类: LINUX

2007-04-05 14:10:50

This page contains mostly outdated information. Most of the answers can be found elsewhere in this wiki, and the rest should be moved there..

 

What is the ''mail environment''?

It is short for the MAIL environment variable.

Dovecot uses the environment to pass information from the master server process to the child processes that handle the individual incoming client connections.

I believe this is not directly related to the MAIL environment variable in a logged-in Unix user's shell. The latter typically points to an mbox file or maildir directory, often outside the user's home directory, where the system MTA delivers new mail.

The server creates this variable modifying a template, by substituting the user name, home directory, and such. The template is taken from the environment (if it has been set in the server environment), from the configuration variable default_mail_env, or from per-user information in a virtual user database.

The value of the variable indicates how mailboxes are stored for the user in question. The value has the format

[ storage_format : ] format_specific_data

(TODO: I have read somewhere that the newer versions of dovecot do/will allow different storage formats for different namespaces.)

The valid storage formats are presently mbox and maildir.

If there is no ':' in the value, dovecot tries to auto-detect a storage format based on the value, which is assumed to be a directory pathname. If no value exists at all, dovecot looks for ~/Maildir and ~/mail, and tries Maildir format for the first, and mbox format for the second.

In the following I describe the format in the case of maildir storage.

After said substitutions, the format of the value of this variable, for Maildir storage, is:

maildir: rootdir [ :INBOX= inboxdir ] [ :INDEX= indexdir ] [ :CONTROL= controldir ]

Do not type the square brackets. They only mark optional parts. The parts in italics are where you supply your own data. All four specify directory paths. Do not put spaces between the values, I have used them only for legibility.

Notice that the mailbox INBOX is special in the imap protocol. If you specify an inbox in the mail environment, any reference to a mailbox called INBOX is redirected to the specified directory. If you leave it out, the specified rootdir is used for the INBOX too. (So even if you see a directory called .INBOX in your Maildir, the contents of INBOX goes directly in Maildir.)

The index part specifies where dovecot stores its indices. It can be specified as MEMORY, but I do not know what happens then. Perhaps the server will not save indices to files but rebuild its indices each time a client connects, or each time a client selects a mailbox.

(TODO: fill in something for the poor mbox users.)

How does new mail get into the Maildir folders?

There are at least two ways; the mail delivery agent just writes it into the folder, and the running imap program discovers the directory contents has changed, or an imap client supplies the mail using an APPEND imap protocol request.

When writing files into a folder, there are some rules to follow. You will normally use the procmail program to do it, because it knows the rules.

On many installations the mail transfer agent (MTA, typically Sendmail) is already set up to use procmail as the final delivery agent. If not, you can usually tell the MTA to use procmail in your $HOME/.forward file.

In your $HOME/.procmailrc file, make sure to add a slash at the end of the folder names. This is how you tell procmail to use the Maildir format. You should stick to using $HOME/.procmailrc files for each user instead of using a system-wide /etc/procmailrc file. Procmail seems to have some intermittent delivery problems if you use the system-wide configuration with Maildir style mailboxes.

Please notice: Dovecot creates a directory .INBOX in the user's ~/Maildir (or whatever was specified as the rootdir in the "mail environment", see the separate question about that). However, if you want new mail to appear in the imap folder INBOX, you must not direct procmail to deliver mail in this directory but in the ~/Maildir or rootdir.

If you define an INBOX in the "mail environment", then you can have procmail deliver to the specified directory.

An inbox specified in the "mail environment" does not need a leading dot in the procmail recipes. For instance,

:0
/var/mail/FrankZappa/

is a valid procmail delivery recipe for a user having mail environment maildir:/home/FrankZappa/Maildir:INBOX=/var/mail/FrankZappa, while a procmail recipe to deliver to an imap folder FanPost could look like this:

MAILDIR=/home/FrankZappa/Maildir
:0
*Subject:.*love you
.FanPost/

To deliver directly to the Maildir (i.e., where INBOX is not specified in the mail environment), you can use a recipe like this:

MAILDIR=/home/FrankZappa/Maildir
:0
./

For ordinary local Unix users, you may want to specify the mail environment as "maildir:%h/Maildir:INBOX=/var/mail/%n". There are two reasons. First, mail can be delivered there without consuming the user's disk quota on the home directory. Second, the user's home directory may prohibit access to any users other than the owner and the privileged user root. Having the INBOX outside the user's home directory permits mail delivery by programs running without root privileges, but belong to the group mail.

I just used procmail to populate a bunch of folders while migrating to dovecot. The directories and files are there, but nothing shows up in imap clients!

In your procmail recipes, you must put a dot at the start of the folder names.

Also remember to use dots to separate hierarchical folder (folders nested inside folders). Nested folders are not created as subdirectories of their parent folders. For instance, you might have the following folder structure:

     .PrivateStuff
     .PrivateStuff.MailsFromJane
     .PrivateStuff.MyLoveAffairs
     .PrivateStuff.MyLoveAffairs.Cinderella
     .PrivateStuff.MyLoveAffairs.Lolita
     .WorkStuff
     .WorkStuff.MailsFromMyBoss
     .WorkStuff.MailsFromCompetitors

In mail clients, and in imap protocol commands, these names show up without the leading dot.

How can I see directly what dovecot says and does?

One thing you can do is connect directly to the dovecot services using a telnet session instead of an email client.

Note that you need to preface each command a line number; type "1 login..." not just "login..."; the IMAP server will echo that number back to you.

> $ telnet localhost imap
  Trying 127.0.0.1...
  Connected to localhost.
  Escape character is '^]'.
  * OK dovecot ready.
> 1 login quique "(!hrRrm!)"
  1 OK Logged in.
> 2 select INBOX
  * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
  * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
  * 0 EXISTS
  * 0 RECENT
  * OK [UIDVALIDITY 1121491607] UIDs valid
  * OK [UIDNEXT 1] Predicted next UID
  2 OK [READ-WRITE] Select completed.
> 3 lsub "" "*"
  * LSUB () "." "Efn"
  * LSUB () "." "Reiserfs"
  * LSUB () "." "Ntp"
  * LSUB () "." "Gtk+"
  * LSUB () "." "Libc"
  * LSUB () "." "Bash"
  * LSUB () "." "Yum"
  * LSUB () "." "Rpm"
  * LSUB () "." "Gimp-Print"
  * LSUB () "." "Indent"
  * LSUB () "." "Licq"
  * LSUB () "." "TexMacs"
  * LSUB () "." "Fontconfig"
  * LSUB () "." "Checkinstall"
  * LSUB () "." "BrlCad"
  * LSUB () "." "Netfilter"
  3 OK Lsub completed.
> 4 subscribe INBOX
  4 OK Subscribe completed.
  ...

I have indicated your inputs with a >. There are no prompts. For a list of valid commands and their arguments, check , section 6. If arguments contain strange characters, like newlines, they must be quoted in one of a range of ways. Double quotation marks as shown above are for the simplest cases.

If you also need to see what the client does... it is not as easy. Depending on what you need, you may want to use a trace command (truss on Solaris, strace on Linux) to attach to the running dovecot process and scan the output for file-related operation. Strace can snoop at the reads and writes on the socket to the client; you may want to specify that more than 32 characters of each read or write are shown in the log. Or, you may use a network sniffer program like tcpdump or ethereal to peep into the protocol exchanges between the client and the server.

You can also connect to the POP3 server; the commands are simpler. The server will say +OK or -ERR after each command.

> telnet localhost pop3
  Trying 127.0.0.1...
  Connected to 127.0.0.1.
  Escape character is '^]'.
  +OK POP3: mail server ready.
> USER testtest
  +OK
> PASS mysecretpassword
  +OK Logged in.
> LIST
  +OK 5 messages:
  1 1107
  2 1107
  3 1107
  4 1107
  5 988
  .
> QUIT
  +OK Logging out.
  Connection closed by foreign host.

Does Dovecot support a single user with a mixture of mail storage formats?

For example, Maildir for INBOX and Unix mailbox for older archives.

"It's possible with 1.0-tests by creating separate namespaces for INBOX and others. Not possible with 0.99 though."

Do all users need to use the same format of mail storage?

default_mail_env can be overridden in userdb for each user. This works with userdbs supporting the "mail" attribute (eg. passwd-file, SQL, LDAP).

If you don't set default_mail_env at all, Dovecot attempts to do automatic detection. In that case it allows either maildir in ~/Maildir or mbox in ~/mail or ~/Mail.

In future perhaps there will also be per-user ~/.dovecotrc which allows specifying where the mails are located.

How do I setup vpopmail auth in dovecot.conf ?

1- You should be sure that "./configure" found vpopmail. When finished, configure shows a summary. You should notice that vpopmail is available as auth module.

2- I´ve compiled vpopmail with --prefix=/var/vpopmail, my dovecot.conf looks like:

auth_userdb = vpopmail
auth_passdb = vpopmail
default_mail_env = maildir:/var/vpopmail/domains/%d/%n/Maildir

3- In the 1.0x versions of dovecot the user's Maildir location is retrieved from vpopmail, and you should not need the 'default_mail_env' line in dovecot.conf.

How do I set the inbox-path in Pine?

The comments in .pinerc suggest the following for reading mail on a remote server:

inbox-path={carsen.u.washington.edu}INBOX

Change "carsen.u.washington.edu" to whatever is appropriate for your setup. If your IMAP server supports SSL or TLS, append "/ssl" or "/tls" to the server name, for example "carsen.u.washington.edu/tls". Another option is to include the username using the "/user=UID" qualifier, for example "carsen.u.washington.edu/ssl/user=timo".

How do I set the IMAP Mailbox Location Prefix in Eudora?

Leave it blank.

How do I set the folder location in Mutt?

What is raw logging?

I don't know.

Why isn't raw logging working?

Possible reasons:

  1. You didn't compile Dovecot with the --with-rawlog flag (0.99.x) or you didn't update mail_executable setting (1.0)
  2. Your user database doesn't specify the home directory for the user. Dovecot doesn't know where to put raw logs if the user database doesn't tell it.
  3. If you are using LDAP, the user_attrs setting in dovecot-ldap.conf doesn't specify homeDirectory. Dovecot will only pull attributes from the LDAP records if they are listed in this setting.
  4. You don't have the dovecot.rawlog directory in the user's home directory. Dovecot will post rawlog entries only if this directory is present.
  5. You have the dovecot.rawlog directory in the wrong directory.

Why can't I change the log location?

Dovecot doesn't change its log location if you change the config file and send the SIGHUP signal with one of the following

kill -1 
kill -HUP 

You have to shutdown Dovecot and restart it. This means sending the TERM signal

kill 
kill -TERM 

Or on FreeBSD (DO NOT EVER TRY THIS ON A SysV MACHINE):

killall dovecot

Or on FreeBSD if you installed from the ports collection:

/usr/local/etc/rc.d/dovecot.sh stop

On recent Solaris versions (>2.7) or Linux with procps:

pkill dovecot

Why can't users access their mail?

Try connecting from the command line.

telnet  imap2

Why can I only connect locally and not remotely (eg. telnet localhost imap2 works and telnet 123.12.21.5 imap2 doesn't)?

Are you sure that imap is listening at the address? Check the imap_listen directive in dovecot.conf. On Linux (maybe others), try "lsof -i | grep LISTEN" to see if it's actually listening on that address. Are you sure your firewall(s) are permitting connections? Fedora, out of the box, regardless if you chose not to run the firewall during install, is on anyway. Kind of Mickeysoft-ish, huh? Try service iptables stop. Careful if you're on the net!

Dovecot isn't running.

Start Dovecot.

Dovecot is running.

The output from the connection attempt is

Connected to mailserver
Escape character is '^]'.
* Dovecot ready

Try logging in from the command line.

1 LOGIN  

Users can't LOGIN.

The output from the login attempt is

1 NO Authentication failed

Possible reasons:

  1. The user isn't in your user database.
  2. The user is in your user database, but there's no password listed.
  3. If you are using LDAP, the pass_attrs setting in dovecot-ldap.conf doesn't specify password.
  4. You misspelled the user name or the password.
  5. You typed the wrong password.

Hint: set "auth_verbose = yes" in dovecot.conf for more information.

The output from the login attempt is

1 NO Login failed: Unsupported authentication mechanism

Possible reasons:

  1. You don't have "auth_mechanisms = plain" for any of your authentication processes. (The above suggested LOGIN command uses plain text authentication.)

Users can LOGIN, but they can't SELECT.

The output from the login attempt is

1 OK logged in

but the output from

2 SELECT 

is

NO Internal error [ 

Possible reasons:

  1. The user database contains a UID number for the user that does not match the owner of the files the mail is stored in.
  2. If you are using LDAP, dovecot-ldap.conf contains a default uid setting that doesn't match the owner of the files the mail is stored in, and the user record in the user database doesn't contain a UID number.
  3. The user's mail files are not in the location specified in the dovecot.conf default_mail_env setting.
  4. Under Debian Stable (woody) if /var/mail is owned by root and group mail, the defaults, the permissions must be drwxrwxrwt or you will get: file_lock_dotlock() failed with mbox file /var/mail/user: Permission denied in /var/log/syslog. See also:

Why isn't Dovecot listening on localhost (127.0.0.1)?

If you specify an interface in dovecot.conf, Dovecot may listen only at that interface and not at localhost. Set

imap_listen = *

Shut down Dovecot completely, and restart it. On FreeBSD, this means instead of using

kill -HUP 

...use one of the following

killall dovecot
kill 
kill -TERM 

Or if you installed Dovecot from the FreeBSD ports collection:

/usr/local/etc/rc.d/dovecot.sh stop

Nothing I do works! I'm losing my sanity! Give me some clues!

I'm sorry. There are no sanity clues.

But you could use some of the techniques detailed in the question "How can I see directly what dovecot says and does?" It often helps getting some insight into what goes on under the hood.

What are the problems mentioned with Hard Quotas?

Commands may fail with "Internal error" messages and users may not be able to even open their mailboxes.

This will probably be fixed before v1.0, but there will always be some theoretical problems that can't be solved (if message UIDs can't be saved, how is it possible to ensure same UID doesn't point to different messages at different times?).

Why is everything in the maildir created with group 1000?

Logged in user's group ID is 1000. See .

Will Dovecot detect a new account simply by adding the mail folders?

Creating new users

For each user Dovecot needs to verify their password and find their mail directory. With maildir you need to do mkdir ~user/Maildir, with mbox mkdir ~user/mail. Your system may use /etc/skel as a template when creating a new system user, so you could mkdir /etc/skel/Maildir or /etc/skel/mail as appropriate.

I believe that in the default configuration Dovecot should automatically allow system users to connect to the mail server. It is possible to add virtual mail users, ie. the Dovecot recognizes them as a user but they are not a real system user. See .

Can Dovecot authenticate and work via UNIX sockets?

Dovecot authentication already works via UNIX sockets, but it only speaks its internal protocol. You could always create a "socket" passdb/userdb. Probably should be made compatible with "checkpassword" protocol. Patches welcome :)

What is the copyright license for Dovecot?

Mostly LGPL () with some bits being MIT () and BSD (). See the COPYING file that comes with the source code.

Why isn't the POP3 service running?

It needs to be added into protocols line in configuration file:

protocols = imap pop3

or if you also want the secure counterparts

protocols = imap imaps pop3 pop3s

Dovecot tells me "Unknown charset"!

If Dovecot returns the error

[BADCHARSET] Unknown charset

and you're running dovecot chrooted to the user's mail directory, then the character set converter included with gnu libc (iconv) can't find its character set files. The easiest way to fix this is to find the shared libraries that comprise the character set conversion (hint: try /usr/lib/gconv and /usr/local/lib/gconv first. If that doesn't work, try "find / -name UNICODE.so -print") and copy them to your chroot.

For instance, if your iconv libraries are in /usr/lib/gconv and your mail chroot is /var/mail then the following should work:

cd /var/mail
mkdir -p usr/lib/gconv
cd usr/lib/gconv
cp -a /usr/lib/gconv/* .

Changes to the configuration files have no effect, what's wrong ?

This could be a hard one, be sure all processes of Dovecot are killed and restarted, just issuing "/etc/init.d/dovecot restart" for example may not be enough, due to that some users may have still their mail clients open, which are running their own processes.

So in my way "/etc/init.d/dovecot restart" did just restart the parent process, but not the processes which were open by the mail client I tested the configuration with, the result was, that all the time I tried to get the configuration right, using this mail client, dovecot didn't take the changes because the process of my test mail client was still running with the old values.

Can I delete the message "DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA" ?

For Dovecot v0.99.x:

If you have migrated from UW-IMAP or have users using Pine (also a UW product) you will see folders which first mail has the subject "DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA".

If you don't have any users using Pine which needs the message then you can remove it safely in each folder.

If you have users who both uses Pine and an IMAP client then they have to live with that message in top of every folder because it get a new timestamp each time it is changed by Pine.

Dovecot 1.0-stable and 1.0-test releases use this message the same way as UW-IMAP/Pine so it shouldn't be removed (but there's no need to do it either, as it's hidden).

How can I make a running dovecot re-read the config file?

For Dovecot 1.0beta3: The following signals can be sent to the dovecot master process. They have some side-effects, don't try them at the servers' busiest hours:

  • SIGHUP: Reload settings. Restarts the auth and login processes. If the updated config file is invalid, it will stick with the old in-memory settings.
  • SIGUSR1: Re-opens the log files.
  • SIGINT, SIGTERM: shuts down dovecot.

 

阅读(8926) | 评论(0) | 转发(0) |
0

上一篇:Dovecot配置文件

下一篇:沁园春·雪

给主人留下些什么吧!~~