1

I have set up Postfix + Dovecot with SSL enforced, and while testing with mailutils I'm able to send e-mails to my gmail, but when I try to reply they are not received on my server.

With openssl I successfully logged in to the imap server with

01 LOGIN myname@example.com mypassword

From which I get

01 OK ....... Logged in

But then on the server I get the following in the syslog

Jul 21 20:51:21 localhost dovecot: imap-login: Login: user=<myname@example.com>, method=PLAIN, rip=99.99.99.99, lip=98.98.98.98, mpid=XXXXX, TLS, session=<R4ND0MSTRINGY>
Jul 21 20:51:21 localhost dovecot: imap(myname@example.com)<XXXXX><R4ND0MSTRINGY>: Error: chdir(/var/mail/vhosts/example.com/myname) failed: Not a directory

I check that file, and it's there, but it's not a directory. It's just an empty file from what I can tell. Does anyone have any idea where my configuration might be wrong? Thanks so much in advance.

simernes
  • 121
  • 1
  • 6
  • 1
    What do you have for `mail_location` ? I'm on Debian, so I have it in `/etc/dovecot/conf.d/10-mail.conf` - Mine is set to `mail_location = maildir:/var/vmail/%d/%n` – ivanivan Jul 22 '19 at 01:11
  • 1
    Additionally, the directory, etc. should be created automagically when the first message is received for the user. Go ahead and remove the file at `/var/mail/vhosts/example.com/myname` and re-send yourself a "welcome" message – ivanivan Jul 22 '19 at 01:12
  • I'm on debian 10, and I have the same mail_location as you do. I think that file I had appeared from when I ran the command `sudo mail -f /var/mail/vhosts/example.com/myname`, but after I removed it and sent another hellow oreld nothing happened. I don't need to configure anything special with DNS do I? I have a mail entry that was created by default by my DNS manager. – simernes Jul 22 '19 at 19:21
  • Actually, i have _almost_ the same as you, mine is including vhosts: `mail_location = maildir:/var/mail/vhosts/%d/%n/`, but after changing it it didn't matter. – simernes Jul 22 '19 at 19:28
  • Can you post the output of `doveconf -n` ? Here is the output of mine, with my domain changed to example.com - https://termbin.com/jdlb – ivanivan Jul 22 '19 at 21:01
  • https://pastebin.com/raw/6j0TeQiU – simernes Jul 22 '19 at 21:39

1 Answers1

1

First you have to ensure you have configured MAILDIR type of storage for your Dovecot server. In /etc/dovecot/conf.d/10-mail.conf this is in parameter

mail_location = maildir:/var/vmail/vhosts/%d/%n

where maildir is the keyword specifying storage type.

Second, you have to create a storage directory

/var/mail/vhosts/example.com/myname

manually, with appropriate ownership, permissions and SELinux labels, or just send some letter to the address, like some simple greetings about "Congrats, myname@example.com, your mailbox created" and this directory will be created by dovecot for you.

MailDir type of storage requires directories to store individual messages in files per every message. It is his main difference of MailDir from older MaiBox storage type keeping all messages in one huge flat file.

KonstantinYu
  • 328
  • 2
  • 5
  • Thank you for answering. I have tried with the same mail location and with appending `vhosts/ after vmail/ and neither worked. I closed all other ports than 993 and 587 though, because I want it all to be encrypted. Do the others need to be open or something for initiation or something of the like? – simernes Jul 22 '19 at 19:34
  • @simernes you need 25 open for server to server SMTP. In your postfix config you can require always using SSL/TLS/ESMTP. – ivanivan Jul 22 '19 at 21:02
  • Thanks, after opening port 25 I can now connect with Thunderbird, and the folder was created with a bunch of content including new, tmp, etc. but I am still not receiving any messages. – simernes Jul 22 '19 at 21:52
  • Your `postmaster_address` is invalid (that should show in the logs) and that has caused issues with storing mail for me in the past. All of this should really be in your log files though, perhaps even visible with `service dovecot status`. This howto may be of help, it is what my config is based on https://workaround.org/ispmail – ivanivan Jul 22 '19 at 22:28
  • "still not receiving any messages" is next issue and not related to this topic. To use dovector as delivery agent you have to specify it in /etc/postfix/main.cf with "virtual_transport = dovecot", then in /etc/postfix/master.cf configure this virtual transport as something like "dovecot unix - n n - - pipe flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop} -m INBOX". – KonstantinYu Jul 23 '19 at 16:31
  • As KonstantinYu said, although I have other issues, the original problem has been solved, and was indeed that port 25 was blocked in UFW. – simernes Jul 28 '19 at 21:21