Mail: Error when communicating with the server

Created on 20 Sep 2017  路  27Comments  路  Source: nextcloud/mail

Steps to reproduce

  1. Create Account Manual

Expected behaviour

Account is created.

Actual behaviour

{"reqId":"WcEx@38AAAEAAFKKb6QAAAAR","level":3,"time":"2017-09-19T15:04:29+00:00","remoteAddr":"nice.ip.addr.1","user":"username","app":"mail","method":"POST","url":"\/index.php\/apps\/mail\/accounts","message":"Creating account failed: Error when communicating with the server.","userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10.12; rv:55.0) Gecko\/20100101 Firefox\/55.0","version":"12.0.3.2"}

Mail app

0.7.3

Mailserver or service: (e.g. Outlook, Yahoo, Gmail, Exchange,...)
Dovecot

Transport security - IMAP: (None, SSL, TLS, STARTTLS)
993, TLS

Login seems to work:

Sep 19 17:04:28 imap-login: Info: Login: user=<username>, method=PLAIN, rip=nextcloud.mailapp, lip=nice.ip.addr.100, mpid=25882, TLS, session=<4TL3LIxZBooFh3us>

Transport security - SMTP: (None, SSL, TLS, STARTTLS)
587,TLS

Number of accounts:
One.

Server configuration


Operating system:
Linux

Web server:
Apache 2.4.27

Database:
MariaDB

PHP version:
7.2.0_rc1

thanks and cheers
t.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

0. to triage

All 27 comments

Hi @himbeere,

please also provide the log entries of your nextcloud.log, horde_imap.log and horde_smtp.log as asked in the issue template. Thanks!

Please check the network tab in your browser's dev console for a possible HTTP error status code and its response.

Hi @ChristophWurst

I did. Under actual behaviour you see the nextcloud.log entry and under "login seems to work" you see the dovecot log.

thanks and cheers
Thomas

I get "400" Bad Request. Hm.

bildschirmfoto 2017-09-20 um 10 06 54

Yes, you provide a bit of log, but not the relevant ones. Please see https://github.com/nextcloud/mail/tree/29bc371e5bac036fb009e6707cd697afd56cd8b3#imap-logging and provide the imap log. It should tell us more about the Error when communicating with the server message.

Moreover you should temporarily set your loglevel to debug and reproduce the issue. Then this app actually logs a lot of information during the setup process. Your log also does not tell where the error/exception occured/was thrown, unfortunately.

Even with "loglevel = 0" there is no more information showing up in the nextcloud.log. Also dovecot is already in "info" mode. https://wiki1.dovecot.org/Logging. Login seems to work though.

Okay, hard to tell what's the issue here. You could try to patch in more logging, but of course on your own risk.

To do so insert $this->logger->logException($ex); after line https://github.com/nextcloud/mail/blob/29bc371e5bac036fb009e6707cd697afd56cd8b3/lib/Controller/AccountsController.php#L224

Then we should get a nice stack trace, which will eventually tell us where an error occurred.

Login seems to work though.

Maybe IMAP login works but the SMTP one fails? 馃

SMTP seems to be the problem, yes.

2017-09-20 11:21:38 TLS error on connection from [nextcloud.mail.app] (SSL_accept): error:00000000:lib(0):func(0):reason(0)
2017-09-20 11:21:38 TLS client disconnected cleanly (rejected our certificate?)

I'll try to play around with the settings a little.

@ChristophWurst Is there a way to tell the mail app which ssl protocols / cipers to use?

I don't think so, no.

Do we know which protocols and cipers mail uses?

No, but I know that we use horde libs for that. So maybe you can find something in its documentation or in its source code.

Yes!

After forcing mail.app to use tlsv1 i ran into another error:

4:09:54 30560 Process 30560 is ready for new message
14:09:54 30560 smtp_setup_msg entered
14:09:54 30560 SMTP<< ??????f???k媳 }?{r#?y?8???w?????/?+?0?,?????????'?#??      ?(?$??
14:09:54 30560 LOG: smtp_syntax_error MAIN
14:09:54 30560   SMTP syntax error in "\026\003\001\002?\001?\001\374\003\003\244\251\261\016f\365\024\354\346k\022\317\261 }\205{r#\223y\2448\234\224\021\366\002\035w\250\031??\202\300/\300+\3000\300,?\236?\242?\243?\237\300'\300#\300\023\300     \300(\300$\300\024\300" H=nextcloud.dev [nice.ip] NULL character(s) present (shown as '?')
14:09:54 30560 SMTP>> 501 NULL characters are not allowed in SMTP commands
14:09:54 30560 SMTP<< ?g?3?@?k?8?9???????????>?2?1?0?1?-?)?%???<?/?????j?i?h?7?6?2?.?*?&???=?5???????????E?D?C?B?A???Q??????
                                                                                                                            domain.de?
                                                                                                                                         ???
14:09:54 30560 LOG: smtp_syntax_error MAIN
14:09:54 30560   SMTP syntax error in "?g?3?@?k?8?9?\234?\235?\244?\240???>?2?1?0\3001\300-\300)\300%\300\016\300\004?<?/?\245?\241?j?i?h?7?6\3002\300.\300*\300&\300\017\300\005?=?5?\210?\207?\206?\205?\204?E?D?C?B?A?\377\001?\001Q???\021?\017??\fdomain.de?\v?\004\003?\001\002?" H=nextcloud.dev [nice.ip] NULL character(s) present (shown as '?')
14:09:54 30560 SMTP>> 501 NULL characters are not allowed in SMTP commands
?4:09:54 30560 SMTP<< ??????????
 ?
  ?     ?
14:09:54 30560 LOG: smtp_syntax_error MAIN
14:09:54 30560   SMTP syntax error in "?\034?\032?\027?\031?\034?\033?\030?\032?\026?\016?\r?\v?\f?     ?" H=nextcloud.dev [nice.ip] NULL character(s) present (shown as '?')
14:09:54 30560 SMTP>> 501 NULL characters are not allowed in SMTP commands
14:09:54 30560 SMTP>> 421 domain.de lost input connection

Exim does not seem to like the input mail.app delivers.

see #382 - configure exim to allow ssmtp and use the proper port. Then you'll have a connection. The issue _seems_ to be that the horde lib doesn't support STARTTLS.

Changing port to 587 does not change anything for me. Still:

TLS error on connection from [nextcloud.mail.app] (SSL_accept): error:00000000:lib(0):func(0):reason(0)
TLS client disconnected cleanly (rejected our certificate?)

it seems I am having the same issue. I get "400" Bad Request. in web console.
I cant seem to enable debugging?
horde_imap.log and horde_smtp.log are not created so I can't really provide a very detailed error report.

I cant seem to enable debugging?

Have you tried https://docs.nextcloud.com/server/12/developer_manual/general/devenv.html#enabling-debug-mode?

@ChristophWurst
no but I tried
'app.mail.imaplog.enabled' => true
and
'app.mail.smtplog.enabled' => true
to create the horde.logs

but interesting enough adding 'app.mail.smtp.timeout' => 20, to config.php might have solved my issue as my account was finally created.

there might be some issues with email address formated like xxx.[email protected]
it seems that it does not like a dot in the name part of the address

I need to look at it a little more and try to get more information for a proper report.

Original issue seems to be fixed, the other ones are unrelated and should be files as new/separate tickets. I'm closing this now.

This issue has not been fixed. Still not able to use the mail app.

Using Dovecot as well, adding the following config fixes account creation, apparently Horde doesn't connect to the SMTP server (postfix in my case) using STARTTLS in the right way.

'app.mail.transport' => 'php-mail'

No direct clues in both Dovecots and Postfix logs as to why this failure occurs.

Unfortunately this workaround only works for sending mail from the local server as the php mail() function has no builtin logic for handling SMTP server connections.

So this is effectively rendering the mail App unusable.

I'll dive into this issue deeper somewhere next week. Any pointers?

read the whole thread incl. references. I'm on the road w/o github access. Use the tls (not starttls) method, This should work. You must enable this in postfix and open the firewall accordingly.
Yes, it's a Horde issue.
No, there is no workaround except: local smtp on the NC server that connects to your postfix as smarthost.

Good luck!

In NC 13.0.6 Mail App creating Gmail account gives still SMTP error.

The config.php entry
'app.mail.transport' => 'php-mail'
works fine for me as a workaround with 2FA and without setting Google to low app security mode.

I use bitpalast.net as hoster.

See https://github.com/nextcloud/mail/blob/master/doc/admin.md

I originally openend this bug. With version NC 15.0.2 and Mail App 0.11.0 everything works for me. So the bug can be closed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jancborchardt picture jancborchardt  路  5Comments

jancborchardt picture jancborchardt  路  4Comments

fsedarkalex picture fsedarkalex  路  5Comments

CHazz picture CHazz  路  3Comments

jancborchardt picture jancborchardt  路  4Comments