# Dovecot IMAP errors: "chdir(/var/mail/$user/) failed: Not a directory", "Root directory is a file: /var/mail/$user"

**URL:** https://forum.yunohost.org/t/dovecot-imap-errors-chdir-var-mail-user-failed-not-a-directory-root-directory-is-a-file-var-mail-user/25895
**Category:** Support
**Tags:** imap, mail, dovecot, postfix, english
**Created:** [August 8, 2023, 3:20am UTC](https://forum.yunohost.org/t/dovecot-imap-errors-chdir-var-mail-user-failed-not-a-directory-root-directory-is-a-file-var-mail-user/25895 "2023-08-08T03:20:02Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![arpy](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/a/bc79bd/32.png) [@arpy](https://forum.yunohost.org/u/arpy)
#### Post date: [August 8, 2023, 3:20am UTC](https://forum.yunohost.org/t/dovecot-imap-errors-chdir-var-mail-user-failed-not-a-directory-root-directory-is-a-file-var-mail-user/25895/1 "2023-08-08T03:20:02Z")

</div>

### My YunoHost server

**Hardware:** eeePC 1005HA  
**YunoHost version:** 11.2.3  
**I have access to my server :**  
✅ Through SSH  
✅ Through the webadmin  
✅ Direct access via keyboard / screen  
**Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?** : no

### Description of my issue

Hello all! Email is (sort of) working on my Yunohost installation. I am using a Yunohost-provided domain, and Gmail as an SMTP relay (as otherwise my ISP blocks it). However, there are persistent errors in the logs, for example in `/var/log/mail.err`:

```auto
Aug 7 22:29:52 $user dovecot: lda($user@$user.noho.st)<278702><BQl2GaCo0WSuQAQA59mD7A>: Error: sieve: msgid=<20230803231607.33A4ED0081E@$user.noho.st>: failed to store into mailbox 'INBOX': Internal error occurred. Refer to server log for more information. [2023-08-07 22:29:52]
Aug 7 22:29:52 $user dovecot: lda($user@$user.noho.st)<278702><BQl2GaCo0WSuQAQA59mD7A>: Error: sieve: Execution of script /etc/dovecot/global_script/rspamd.sieve was aborted due to temporary failure
Aug 7 22:34:52 $user dovecot: lda($user@$user.noho.st)<278800><Qsk5M8yp0WQQQQQA59mD7A>: Error: chdir(/var/mail/$user) failed: Not a directory
Aug 7 22:34:52 $user dovecot: lda($user@$user.noho.st)<278800><Qsk5M8yp0WQQQQQA59mD7A>: Error: stat(/var/mail/$user/tmp) failed: Not a directory

```

And in `journalctl`:

```auto
Aug 07 17:35:37 dovecot[260525]: imap($user)<268335><jlD6BlwCcLf+gAAAAAAAAEpbOf/+FZWY>: Error: Root directory is a file: /var/mail/$user

```

Based on [this Serverfault question](https://serverfault.com/questions/764922/change-dovecot-mail-directory) I think it may have something to do with [dovecot mail location settings](https://doc.dovecot.org/configuration_manual/mail_location/#mail-location-settings), and maybe Maildir vs. mbox format.

Does anyone know how to fix this? Or at least what would help further diagnose the problem?

P. S. Full logs if it will help:  
[Postfix logs](https://paste.yunohost.org/ecadojobug)  
[Dovecot logs](https://paste.yunohost.org/uhuhilazod)

---

<div class="post-metadata">

### Author: ![Aleks](https://forum.yunohost.org/user_avatar/forum.yunohost.org/aleks/32/1704_2.png) [@Aleks](https://forum.yunohost.org/u/Aleks)
#### Post date: [August 9, 2023, 3:02pm UTC](https://forum.yunohost.org/t/dovecot-imap-errors-chdir-var-mail-user-failed-not-a-directory-root-directory-is-a-file-var-mail-user/25895/2 "2023-08-09T15:02:43Z")

</div>

Hmmmokay can we check what `ls -l /var/mail/pang` returns ? (And can you confirm that it’s an username on your server, registered as a YunoHost user ?)

---

<div class="post-metadata">

### Author: ![arpy](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/a/bc79bd/32.png) [@arpy](https://forum.yunohost.org/u/arpy)
#### Post date: [August 9, 2023, 4:27pm UTC](https://forum.yunohost.org/t/dovecot-imap-errors-chdir-var-mail-user-failed-not-a-directory-root-directory-is-a-file-var-mail-user/25895/3 "2023-08-09T16:27:46Z")

</div>

Thanks! It returns:

`-rw-rw---- 1 pang mail 0 May 7 2022 /var/mail/pang`

`pang` is my account, the main one.

---

<div class="post-metadata">

### Author: ![Aleks](https://forum.yunohost.org/user_avatar/forum.yunohost.org/aleks/32/1704_2.png) [@Aleks](https://forum.yunohost.org/u/Aleks)
#### Post date: [August 9, 2023, 4:41pm UTC](https://forum.yunohost.org/t/dovecot-imap-errors-chdir-var-mail-user-failed-not-a-directory-root-directory-is-a-file-var-mail-user/25895/4 "2023-08-09T16:41:01Z")

</div>

> [@arpy](#):
>
> -rw-rw---- 1 pang mail 0 May 7 2022 /var/mail/pang

Hmyeah so indeed this is a file and not a folder … not sure how this can even happen … But anyway it’s empty (size=0) so we can safely delete it with : `rm /var/mail/pang`

---

<div class="post-metadata">

### Author: ![arpy](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/a/bc79bd/32.png) [@arpy](https://forum.yunohost.org/u/arpy)
#### Post date: [August 9, 2023, 5:01pm UTC](https://forum.yunohost.org/t/dovecot-imap-errors-chdir-var-mail-user-failed-not-a-directory-root-directory-is-a-file-var-mail-user/25895/5 "2023-08-09T17:01:14Z")

</div>

Thank you so much, that seems to have fixed things! It is now working fine.

---

<div class="post-metadata">

### Author: ![system](https://forum.yunohost.org/uploads/default/original/2X/f/f59fe8e3ee6b100b4f574d30d6e30479c68b89f0.png) [@system](https://forum.yunohost.org/u/system)
#### Post date: [September 8, 2023, 5:01pm UTC](https://forum.yunohost.org/t/dovecot-imap-errors-chdir-var-mail-user-failed-not-a-directory-root-directory-is-a-file-var-mail-user/25895/6 "2023-09-08T17:01:44Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
