Search code examples
mysqlemailimappostfix-mtadovecot

Why after create an email in MySQL (mail server) cannot be accessed?


I'm using Amazon EC2 + MySQL + SES + Postfix + Dovecot + Roundcube

  1. I create the email in mysql database.
  2. I go to the webmail (roundcube) to login in the recipient but I get an IMAP error.
  3. I send a test email to the <recipient@> and the email arrives well.
  4. I go to the webmail (roundcube) to login to the recipient and it works now.

How can I start using the mailbox in the step 2 (after created) and not after receive the first email?

Another important point is the command: tail -f /var/log/mail.log

When I try to login appears this:

For example I created a test recipient [email protected], the log shows this after try to login:

Sep 17 19:44:46 ip-172-31-20-63 dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=4236, secured

Sep 17 19:44:46 ip-172-31-20-63 dovecot: imap([email protected]): Error: User initialization failed: Namespace 'INBOX.': Ambiguous mail location setting, don't know what to do with it: /var/spool/mail/virtual/test21/ (try prefixing it with mbox: or maildir:)

Sep 17 19:44:46 ip-172-31-20-63 dovecot: imap: Error: Invalid user settings. Refer to server log for more information.

UPDATE: I know now two things more that helps me to solve the problem, the first solves the problem but I need to create folders manually for each new mailbox, and the second is suposed should work but it doesn't. There is:

1) Create the maildirs and add permissions:

mkdir /var/spool/mail/virtual/<recipient>
mkdir /var/spool/mail/virtual/<recipient>/cur
mkdir /var/spool/mail/virtual/<recipient>/new
mkdir /var/spool/mail/virtual/<recipient>/tmp

And finally again:

sudo chown -R virtual:virtual /var/spool/mail/virtual

2) The second option founded here (https://www.digitalocean.com/community/questions/ubuntu-mail-server-postfix-dovecot-create-default-inbox-sent-and-trash-folder-per-account) is:

Modify the dovecot flags in /etc/dovecot/conf.d/20-imap.conf, as said in the comments of the article:

protocol imap {
    mail_plugins = $mail_plugins autocreate
}

plugin {
    autocreate = Trash
    autocreate2 = Junk
    autocreate3 = Drafts
    autocreate4 = Sent
    autosubscribe = Trash
    autosubscribe2 = Junk
    autosubscribe3 = Drafts
    autosubscribe4 = Sent
}

Thanks, any help.


Solution

  • I found a solution, when the first email comes to the new mailbox the folders are created, for that reason what I need to do, is to enable the new email account sending a new email to it using:

    mail -s "Create email" [email protected]
    Cc:
    Welcome ! 
    <Ctrl+D>
    

    I will creating a new php application to create the new emails.

    Bye!