# main.cf (postfix) & 10-mail.conf (dovecot2): Correct settings?



## sidney2017 (Oct 4, 2020)

Hello everybody,

I set up a FreeBSD 11.4 system with postfix 3.5.7.1, dovecot 2.3.11.3, dovecot-pigeonhole 0.5.11 and roundcube-php74-1.4.9,1 working with virtual users.

All works as expected, with one exception: problems with server-side sieve filters.
The error log shows up:



> imap(user@domain.tld)<51952><PWnZSdWwA71/AAAB>: *Error: stat(/var/mail/vhosts/ user@domain.tld /user/.dovecot.sieve/tmp) failed: Not a directory*



According to several sources on the WWW, that sieve-error message depends on the fact that the HOME directory is used as the MAILDIR directory.

Since this is a freshly set up system, I still have the possibility to configure the whole thing from the beginning in a way that the described problem is no longer caused by using the HOME directory as MAILDIR directory.

*My question is:*

In my *10-mail.conf for Dovecot2* currently you find:

```
mail_home = /var/mail/vhosts/%d/%n
mail_location = maildir:~
```

*main.cf (postfix):*

```
home_mailbox = Maildir/
virtual_mailbox_base = /var/mail/vhosts
```

Can anyone tell me which modifications I have to make in 10-mail.conf and main.cf to fulfill following recommendations from https://wiki2.dovecot.org/VirtualUsers/Home:


> *Home vs. mail directory
> 
> Home directory shouldn't be the same as mail directory with mbox or Maildir formats* (but with dbox/obox it's fine). It's possible to do that, but you might run into trouble with it sooner or later.




Many greetings
sidney2017


----------



## VladiBG (Oct 5, 2020)

Check the configuration of your /usr/local/etc/dovecot/conf.d/90-plugin.conf file

Comment out your home_mailbox in mail.cf
Comment out your mail_home in 10-mail.conf

Then set as following

/usr/local/etc/dovecot/conf.d/10-mail.conf
`mail_location = maildir:/var/mail/vhosts/%d/%n`

/usr/local/etc/postfix/main.cf
`virtual_mailbox_base = /var/mail/vhosts`

/usr/local/etc/dovecot/conf.d/90-plugin.conf

```
plugin {
  sieve = /var/mail/vhosts/%d/%n/.dovecot.sieve
  sieve_dir = /var/mail/vhosts/%d/%n/sieve
  sieve_global_dir = /var/mail/vhosts/default.sieve
  mail_home = /var/mail/vhosts/%d/%n
}
```

Don't forget to create the /var/mail/vhosts and give the permissions of the users under you are running your postfix , dovecot and virus scan.

Edit:
sieve_dir and sieve_global_dir are now deprecated


			Pigeonhole/Sieve/Configuration - Dovecot Wiki


----------



## sidney2017 (Oct 5, 2020)

Hello,


thank you very much for your support. I wonder where in the WWW you can find hints that changes have to be made in 90-plugin.conf as well? Before I posted here, I spent the whole weekend using search engines to find solutions.

When I activate and save the Out of Office Assistant in Roundcube, I get an error message. In the logfiles this message appears as follows:

*/var/log/dovecot.log*


```
Oct 05 10:09:48 auth: Debug: passwd-file(user@domain.tld,127.0.0.1,<PyGOAeiwSDh/AAAB>): Performing passdb lookup
Oct 05 10:09:48 auth: Debug: passwd-file(user@domain.tld,127.0.0.1,<PyGOAeiwSDh/AAAB>): lookup: user=user@domain.tld file=/usr/local/etc/dovecot/users
Oct 05 10:09:48 auth: Debug: passwd-file(user@domain.tld,127.0.0.1,<PyGOAeiwSDh/AAAB>): Finished passdb lookup
Oct 05 10:09:48 auth: Debug: auth(user@domain.tld,127.0.0.1,<PyGOAeiwSDh/AAAB>): Auth request finished
Oct 05 10:09:48 auth: Debug: client passdb out: OK      1       user=user@domain.tld
Oct 05 10:09:48 auth: Debug: master in: REQUEST 1021313025      68810   1       3a158b54081624c84a3e6c0d3d6a5d1c        session_pid=68811
Oct 05 10:09:48 auth: Debug: passwd-file(user@domain.tld,127.0.0.1,<PyGOAeiwSDh/AAAB>): Performing userdb lookup
Oct 05 10:09:48 auth: Debug: passwd-file(user@domain.tld,127.0.0.1,<PyGOAeiwSDh/AAAB>): lookup: user=user@domain.tld file=/usr/local/etc/dovecot/users
Oct 05 10:09:48 auth: Debug: passwd-file(user@domain.tld,127.0.0.1,<PyGOAeiwSDh/AAAB>): Finished userdb lookup
Oct 05 10:09:48 auth: Debug: master userdb out: USER    1021313025      user@domain.tld              auth_mech=PLAIN
Oct 05 10:09:48 managesieve-login: Info: Login: user=<user@domain.tld>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=68811, secured, session=<PyGOAeiwSDh/AAAB>
Oct 05 10:09:48 managesieve(user@domain.tld)<68811><PyGOAeiwSDh/AAAB>: Debug: Added userdb setting: plugin/=yes
Oct 05 10:09:48 managesieve(user@domain.tld)<68811><PyGOAeiwSDh/AAAB>: Debug: Effective uid=1001, gid=1001, home=
Oct 05 10:09:48 managesieve(user@domain.tld)<68811><PyGOAeiwSDh/AAAB>: Debug: Namespace inbox: type=private, prefix=, sep=, inbox=yes, hidden=no, list=yes, subscriptions=yes location=maildir:/var/mail/vhosts/user@domain.tld/user
Oct 05 10:09:48 managesieve(user@domain.tld)<68811><PyGOAeiwSDh/AAAB>: Debug: maildir++: root=/var/mail/vhosts/user@domain.tld/user, index=, indexpvt=, control=, inbox=/var/mail/vhosts/user@domain.tld/user, alt=
Oct 05 10:09:48 managesieve(user@domain.tld)<68811><PyGOAeiwSDh/AAAB>: Debug: sieve: Pigeonhole version 0.5.11 (d71e0372) initializing
Oct 05 10:09:48 managesieve(user@domain.tld)<68811><PyGOAeiwSDh/AAAB>: Debug: sieve: include: sieve_global is not set; it is currently not possible to include `:global' scripts.
Oct 05 10:09:48 managesieve(user@domain.tld)<68811><PyGOAeiwSDh/AAAB>: Error: sieve: file storage: Sieve storage path `~/sieve' is relative to home directory, but home directory is not available.
Oct 05 10:09:48 managesieve(user@domain.tld)<68811><PyGOAeiwSDh/AAAB>: Fatal: Failed to open Sieve storage.
```

*Roundcube error.log*


```
[05-Oct-2020 08:09:48 +0000]: <ecdb61c0> PHP Error: BYE "Internal error occurred. Refer to server log for more information. [2020-10-05 10:09:48]" (POST /roundcube/?_task=settings&_action=plugin.managesieve-vacation)
[05-Oct-2020 08:09:48 +0000]: <ecdb61c0> PHP Error: Unable to connect to managesieve on localhost:4190 in /usr/local/www/roundcube/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php on line 223 (POST /roundcube/?_task=settings&_action=plugin.managesieve-vacation)
[05-Oct-2020 08:09:48 +0000]: <ecdb61c0> PHP Error: Not currently connected (POST /roundcube/?_task=settings&_action=plugin.managesieve-vacation)
```

This should not have anything to do with permissions for /var/vhosts, because I once tested setting this folder recursively to 777 after the above error message appeared.

It looks like if the setting
sieve_global_path = /var/mail/vhosts/default.sieve
in 90-plugin.conf  is not accepted or overwritten somewhere:

*dovecot.log*

```
Sieve storage path `~/sieve' is relative to home directory, but home directory is not available.
```

Any idea to solve that problem?

Thanks in advance and kind regards
sidney2017

P.S.: I guess you meant main.cf and not mail.cf. Maybe important for users with the same problem reading here your hints in future.


----------



## VladiBG (Oct 5, 2020)

Yes main.cf not mail.cf sorry about that.



			Postfix Documentation
		



			Dovecot manual — Dovecot documentation
		



			Pigeonhole/Sieve/Configuration/File - Dovecot Wiki
		



To Other users:
Do not follow blindly any howtos/guides from internet. Only source of documentation that you need is the official manual of the program that you are using.

NOTE:
You should limit the access of the /var/mail/vhosts only to the user group of the processes which need read/write access to this directory.

NOTE2:
sieve_global_dir = (< v0.3.1)  must be changed to sieve_global as sieve_global_dir is deprecated.
sieve_dir = ~/sieve (< v0.3.1)  must be changed to sieve settings https://wiki.dovecot.org/Pigeonhole/Sieve/Configuration#Per-user_Sieve_script_location
for more info: https://wiki.dovecot.org/Pigeonhole/Sieve/Configuration#Deprecated_Settings



> sieve_dir = ~/sieve (< v0.3.1)
> Directory for personal include scripts for the include extension. The Sieve interpreter only recognizes files that end with a .sieve extension, so the include extension expects a file called name.sieve to exist in the sieve_dir directory for a script called name. When using ManageSieve, this is also the directory where scripts are uploaded. For recent Pigeonhole versions, this location is configured as part of the sieve setting.


----------



## sidney2017 (Oct 5, 2020)

Hi,

thank you very much for your hints mentioned above!

I replaced the settings in /usr/local/etc/dovecot/conf.d/90-plugin.conf  as recommended by you:


```
plugin {
  -e = /var/mail/vhosts/%d/%n/.dovecot.sieve
  sieve = /var/mail/vhosts/%d/%n/sieve
  sieve_global = /var/mail/vhosts/default.sieve
  mail_home = /var/mail/vhosts/%d/%n
}
```

I restartet dovecot with _service dovecot restart

/var/mail/vhosts recursively _is owned by vpostfix:vpostfix with permissions 775.

In group vpostfix following users have been defined:

```
vpostfix:*:1001:vscan,dovecot,postfix,spamd,clamav
```

Unfortunately the same errors described above occur and in Roundcube activating the out-of-office-assistant and saving the message still throws a "_unable to connect to server_".


```
sockstat -l4 | grep -i 4190
root     dovecot    90267 15 tcp4   *:4190                *:*
```

Do you have another idea what could be the cause of the problem?


Thanks in advance and best regards
sidney2017


----------



## VladiBG (Oct 5, 2020)

remove this -e this is mistype from sieve (i fixed it in my first post)
here how my config look like



> plugin {
> sieve = /mail/%d/%n/.dovecot.sieve
> sieve_dir = /mail/%d/%n/sieve
> sieve_global_path = /mail/default.sieve
> ...



_I know i have to update my configs also as they are deprecated._

After that reload your dovecot config and verify also your setting for managesieve_default in /usr/local/www/roundcube/plugins/managesieve/config.inc.php

`$config['managesieve_default'] = '/var/mail/vhosts/default.sieve';`

Note:
i'm using /mail as it's mounted on different raid volume.


----------



## sidney2017 (Oct 5, 2020)

Hi,

my /usr/local/etc/dovecot/conf.d/90-plugin.conf now looks like following:


```
plugin {
  sieve = /var/mail/vhosts/%d/%n/.dovecot.sieve
  sieve_dir = /var/mail/vhosts/%d/%n/sieve
  sieve_global = /var/mail/vhosts/default.sieve
  mail_home = /var/mail/vhosts/%d/%n
}
```

But if you compare it with the settings you recommended first you see that the new set _sieve_dir _= now contains the path of _sieve_ = (former 90-plugin.conf).

Former:

```
plugin {
  -e = /var/mail/vhosts/%d/%n/.dovecot.sieve
  sieve = /var/mail/vhosts/%d/%n/sieve
  sieve_global = /var/mail/vhosts/default.sieve
  mail_home = /var/mail/vhosts/%d/%n
}
```


Additionally I added in managesieve/config.inc.php:


> $config['managesieve_default'] = '/var/mail/vhosts/default.sieve';


and restartet dovecot.

But the error obviously is very "persistent" because I still get the same error messages, when trying to set up a filter in roundcube.

For example  roundcube/logs/errors-log shows:


> PHP Error: Unable to connect to managesieve on localhost:4190



Kind regards and thanks for your patience
sidney2017








						main.cf (postfix) & 10-mail.conf (dovecot2): Correct settings?
					

Hello everybody,  I set up a FreeBSD 11.4 system with postfix 3.5.7.1, dovecot 2.3.11.3, dovecot-pigeonhole 0.5.11 and roundcube-php74-1.4.9,1 working with virtual users.  All works as expected, with one exception: problems with server-side sieve filters. The error log shows up...




					forums.freebsd.org


----------



## VladiBG (Oct 5, 2020)

Are getting the same error ?
"sieve: file storage: Sieve storage path `~/sieve' is relative to home directory, but home directory is not available."

Check the actual config with
`doveconf -a`
And see if your mail_home is set under plugins.


----------



## sidney2017 (Oct 5, 2020)

Hi,

yes, the error message still is:


```
05 16:47:04 managesieve-login: Info: Login: user=<user@domain.tld>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=61522, secured, session=<cVtHju2wkbF/AAAB>
Oct 05 16:47:04 managesieve(user@domain.tld)<61522><cVtHju2wkbF/AAAB>: Debug: Added userdb setting: plugin/=yes
Oct 05 16:47:04 managesieve(user@domain.tld)<61522><cVtHju2wkbF/AAAB>: Debug: Effective uid=1001, gid=1001, home=
Oct 05 16:47:04 managesieve(user@domain.tld)<61522><cVtHju2wkbF/AAAB>: Debug: Namespace inbox: type=private, prefix=, sep=, inbox=yes, hidden=no, list=yes, subscriptions=yes location=maildir:/var/mail/vhosts/domain.tld/user
Oct 05 16:47:04 managesieve(user@domain.tld)<61522><cVtHju2wkbF/AAAB>: Debug: maildir++: root=/var/mail/vhosts/domain.tld/user, index=, indexpvt=, control=, inbox=/var/mail/vhosts/domain.tld/user, alt=
Oct 05 16:47:04 managesieve(user@domain.tld)<61522><cVtHju2wkbF/AAAB>: Debug: sieve: Pigeonhole version 0.5.11 (d71e0372) initializing
Oct 05 16:47:04 managesieve(user@domain.tld)<61522><cVtHju2wkbF/AAAB>: Error: sieve: file storage: Sieve storage path `~/sieve' is relative to home directory, but home directory is not available.
Oct 05 16:47:04 managesieve(user@domain.tld)<61522><cVtHju2wkbF/AAAB>: Fatal: Failed to open Sieve storage.
```


dovecot -a



> ...
> passdb {
> args = scheme=CRYPT username_format=%u /usr/local/etc/dovecot/users
> auth_verbose = default
> ...



May the problem derive from the entry
*sieve = file:~/sieve;active=~/.dovecot.sieve*
which should be
*sieve = /var/mail/vhosts/%d/%n/.dovecot.sieve*
as defined in 90-plugin.conf?


*EDIT #1:*
Obviously sieve = defined in 90-plugin.conf is overwritten by
sieve = in 90-sieve.conf.

*90-sieve.conf*


> plugin {
> # The location of the user's main Sieve script or script storage. The LDA
> # Sieve plugin uses this to find the active script for Sieve filtering at
> # delivery. The "include" extension uses this location for retrieving
> ...



I am just testing it after having commented out _sieve =_ in 90-sieve.conf.

*EDIT #2:*

Indeed _sieve =_ was overwritten in 90-plugin.conf.
Commenting out _sieve =_ *in 90-sieve.conf*
removed the error message.

However, the absence filters unfortunately still do not trigger activation. The sender does not get an autoreply.


Thanks again for your assistance
sidney2017


----------



## VladiBG (Oct 5, 2020)

try this:



> plugin {
> mail_home = /var/mail/vhosts/%d/%n
> sieve = file:/var/mail/vhosts/%d/%n/sieve;active=/var/mail/vhosts/%d/%n/.dovecot.sieve
> sieve_global = /var/mail/vhosts/default.sieve
> }



Also check in the user folder there must be folder called sieve and a link pointing to that folder active script. This is created by the dovecot so no need to be created manually.

Do you have empty file  /var/mail/vhosts/default.sieve


----------



## sidney2017 (Oct 5, 2020)

Now you removed sieve_dir = from 90-plugin.conf, correct?

*NO*, I cannot find a file named *default.sieve* under /var/mail/vhosts

In my user folder
/var/mail/vhosts/domain.tld/user
there was a .dovecot-sieve symlink pointing to sieve/roundcube.sieve.

For testing I have deleted /var/mail/vhosts/domain.tld/user/.dovecot.sieve and
/var/mail/vhosts/domain.tld/user/sieve/

Afterwards I restartet dovecot but both - .dovecot.sieve and /sieve are not recreated again.

*doveconf -a | grep -i sieve*


> managesieve_client_workarounds =
> managesieve_implementation_string = Dovecot Pigeonhole
> managesieve_logout_format = bytes=%i/%o
> managesieve_max_compile_errors = 5
> ...



There is a space in *" sieve"!*
Ist this normal?

Actually I wanted to move away from sendmail to postfix and dovecot, because these components were supposedly a bit easier to handle. But that is probably more a rumor.

Greetings
sidney2017


----------



## sidney2017 (Oct 5, 2020)

VladiBG said:


> try this:
> 
> Also check in the user folder there must be folder called sieve and a link pointing to that folder active script. This is created by the dovecot so no need to be created manually.
> 
> Do you have empty file  /var/mail/vhosts/default.sieve



Meanwhile I reinserted "sieve_dir = ..." in 90-plugin.conf:
(I hope that sieve_dir = /var/mail/vhosts/%d/%n/sieve is correct.


```
plugin {
mail_home = /var/mail/vhosts/%d/%n
sieve_dir = /var/mail/vhosts/%d/%n/sieve
sieve = file:/var/mail/vhosts/%d/%n/sieve;active=/var/mail/vhosts/%d/%n/.dovecot.sieve
sieve_global = /var/mail/vhosts/default.sieve
}
```

Now a new ".dovecot.sieve" symlink has been created
=> /var/mail/vhosts/domain.tld/user/sieve/*managesieve.sieve*

What surprises me: The old symbolic link ".dovecot.sieve" I renamed had pointed to
=> /var/mail/vhosts/domain.tld/user/sieve/*roundcube.sieve*

So I wonder what is correct? managesieve.sieve or roundcube.sieve?

*/var/mail/vhosts/default.sieve *still is NOT created although
*sieve_global = /var/mail/vhosts/default.sieve* is defined in 90-plugin.conf

And *doveconf -n | grep -i sieve *prints out:
sieve_global = /var/mail/vhosts/default.sieve

I can send and receive emails and set up filters in Roundcube, but thoses filters unfortunately still are not triggered.

Kind regards
sidney2017


----------



## VladiBG (Oct 6, 2020)

You can have different .sieve scripts inside your /sieve/ directory. I'm using managesieve.sieve to store out of office. The simlink which is created by dovecot point to the active .sieve script.
Do you have sieve plugin activated in your lda and lmtp protocol config?

mail_plugins = $mail_plugins sieve


----------



## sidney2017 (Oct 6, 2020)

Hi,

here is the content of dovecot/conf.d/*15-lda.conf*:

```
protocol lda {
  # Space separated list of plugins to load (default is global mail_plugins).
  mail_plugins = $mail_plugins sieve
}
```

*20-lmtp.conf:*

```
protocol lmtp {
  # Space separated list of plugins to load (default is global mail_plugins).
  #mail_plugins = $mail_plugins
  mail_plugins = $mail_plugins sieve
}
```

*doveconf -a*


> # 2.3.11.3 (502c39af9): /usr/local/etc/dovecot/dovecot.conf
> # Pigeonhole version 0.5.11 (d71e0372)
> ...
> mail_home =
> ...



Best regards
Sidney2017


----------



## VladiBG (Oct 6, 2020)

Looks correct, what you error you getting now in the log files?


----------



## sidney2017 (Oct 6, 2020)

No error message!

But the out-of-office message and/or other rules defined in Roundcube are not fired up. But they are saved on the storage.

Kind regards
sidney2017


----------



## VladiBG (Oct 6, 2020)

Check if the managesieve.sieve is your default script file and if the link .dovecot.sieve is pointing to it.
Also you can use sieve-test to test the script.


----------



## sidney2017 (Oct 6, 2020)

Are you sure that
*sieve_global *= /var/mail/vhosts/default.sieve is correct?

Shouldn´t it be:
*sieve_defaut *= /var/mail/vhosts/default.sieve instead?

Anyway: Even a
sieve_default = /var/mail/vhosts/default.sieve does not create a default.sieve under /var/mail/vhosts.

I removed the old directory contents and started postfix and dovecot again. 
The structures have been recreated:

/var/mail/vhosts/domain.tld/user/.dovecot.sieve => /var/mail/vhosts/domain.tld/user/sieve/managesieve.sieve

Bit still the filters are not triggered! :-(

Kind regards
sidney2017


----------



## VladiBG (Oct 6, 2020)

sieve_global_path = (< v0.2)
The deprecated name for the sieve_default setting.

default.sieve must be created by you.


----------



## sidney2017 (Oct 6, 2020)

> *sieve_default = (v0.3+)*
> 
> The *location of the default personal sieve script* file which gets executed ONLY if user's private Sieve script does not exist, e.g. file:/var/lib/dovecot/default.sieve (check the multiscript section for instructions on running global Sieve scripts before and after the user's personal script). This is usually a global script, so be sure to pre-compile the specified script manually in that case using the sievec command line tool, as explained here. This setting used to be called sieve_global_path, but that name is now deprecated.
> 
> Source: https://wiki2.dovecot.org/Pigeonhole/Sieve/Configuration



So I wonder why you used sieve_global above?

Kind Regards
sidney2017


----------



## VladiBG (Oct 6, 2020)

It must be sieve_global_path or sieve_default



> sieve_global_dir = (< v0.3.1)
> Directory for :global include scripts for the include extension. The Sieve interpreter only recognizes files that end with a .sieve extension, so the include extension expects a file called name.sieve to exist in the sieve_global_dir directory for a script called name. For recent Pigeonhole versions, a more generic version of this setting is called sieve_global and allows locations other than file system directories.



This is my plugin configuration which works.


```
plugin {
  expire = Trash
  mail_home = /mail/%d/%n
  mail_log_events = delete undelete expunge copy mailbox_delete mailbox_rename
  mail_log_fields = uid box msgid size
  quota = maildir:User quota
  quota_exceeded_message = Storage quota for this account has been exceeded, please try again later.
  quota_rule = *:storage=1G
  quota_rule2 = Trash:storage=+30%%
  quota_rule3 = Sent:storage=+30%%
  quota_warning = storage=90%% quota-warning 90 %u
  quota_warning2 = storage=75%% quota-warning 75 %u
  sieve = /mail/%d/%n/.dovecot.sieve
  sieve_dir = /mail/%d/%n/sieve
  sieve_global_path = /mail/default.sieve
}
```


----------

