Mail Provisioning with UserExternal\IMAP

Hello,

I’ve a Dovecot server running email and I’ve successfully configured NextCloud to use it for logins with the IMAP backed:

'user_backends' => array(
    array(
        'class' => '\OCA\UserExternal\IMAP',
        'arguments' => array(
            'my.server.example.org', 993, 'ssl', null, true, false
        ),
    ),
  ),

Users can login just fine, however I want to have their email configuration automatically provisioned after the first login and for that I tried this:

After applying the config for all users the Mail app tab takes a long time to load and eventually loads like this:

On my IMAP server I got these logs:

 dovecot[9155]: imap-login: Disconnected (auth failed, 4 attempts in 35 secs): user=<%EMAIL%>, method=PLAIN, rip=10.10.125.7, lip=10.10.125.4, TLS, session=<AlQT2gv7JOcKCn0H>
 dovecot[9155]: imap-login: Disconnected (auth failed, 4 attempts in 61 secs): user=<%EMAIL%>, method=PLAIN, rip=10.10.125.7, lip=10.10.125.4, TLS, session=<UZXb2gv7nJ4KCn0H>
 dovecot[9155]: imap-login: Disconnected (auth failed, 4 attempts in 35 secs): user=<%EMAIL%>, method=PLAIN, rip=10.10.125.7, lip=10.10.125.4, TLS, session=<5BXi3wv7dOAKCn0H>

It says that “* %USERID% and %EMAIL% will be replaced with the user’s UID and email” but apparently it doesn’t replace the %EMAIL% placeholder with the login email as we can see on the log.

What am I missing?

I also tried to setup this in my config.json as follows but it doesn’t even seem to do any kind of configuration:

  'app.mail.accounts.default' => [
    'email' => '%EMAIL%',
    'imapHost' => 'env...',
    'imapPort' => 993,
    'imapUser' => '%EMAIL%',
    'imapSslMode' => 'ssl',
    'smtpHost' => 'en.....',
    'smtpPort' => 587,
    'smtpUser' => '%EMAIL%',
    'smtpSslMode' => 'tls',
  ]

Note: my users will login with 2 different domains using their full e-mail address. The IMAP and SMTP require login with the full e-mail as well.

Thank you.