Help! Unexpected error during account creation - Error connecting to SMTP server

Hello! I am a novice trying to setup Nextcloud for the first time have run into issues as soon as I try to configure mail. I have spent hours researching and trying forum solutions and am stuck. I am hoping that maybe someone on here might know how to get it working?

Background:

  • I am hosted with godaddy using cPanel mail, and using an add-on domain with a wordpess site on it. The mail settings require SSL.
  • The mail successfully configures and works with ms outlook on desktop and stock phone mail apps without issue.
  • When trying to connect to Nextcloud using the same settings, I get an error saying “Unexpected error during account creation.” The logs suggests that there is an error connecting to the SMTP server, but no error connecting to IMAP (pasted below, please verify, I don’t know what I’m doing).

I have tried this in the config file based on other issues/forums (again, I don’t know what I’m doing):
‘mail_smtptimeout’ => ‘30’,
‘mail_smtptimeout’ => 30,
‘app.mail.transport’ => ‘php-mail’
‘app.mail.verify-tls-peer’ => ‘false’,
‘app.mail.verify-tls-peer’ => false,

Error Logs:

  • nextcloud.log:

{“reqId”:“X2PE7IEvn9wRsMjtQTNwTwACiwk”,“level”:3,“time”:“2020-09-17T20:19:56+00:00”,“remoteAddr”:“76.121.102.127”,“user”:“oh84f1”,“app”:“side_menu”,“method”:“POST”,“url”:“/cloud/index.php/apps/mail/api/accounts”,“message”:{“Exception”:“RuntimeException”,“Message”:“App class OCA\SideMenu\AppInfo\Application is not setup via query() but directly”,“Code”:0,“Trace”:[{“file”:“/home/pnwhomesolutions/public_html/localhost/cloud/apps/side_menu/lib/AppInfo/Application.php”,“line”:41,“function”:“__construct”,“class”:“OCP\AppFramework\App”,“type”:“->”,“args”:[“side_menu”,]},{“file”:“/home/pnwhomesolutions/public_html/localhost/cloud/apps/side_menu/appinfo/app.php”,“line”:5,“function”:“__construct”,“class”:“OCA\SideMenu\AppInfo\Application”,“type”:“->”,“args”:},{“file”:“/home/pnwhomesolutions/public_html/localhost/cloud/lib/private/legacy/OC_App.php”,“line”:266,“args”:[“/home/pnwhomesolutions/public_html/localhost/cloud/apps/side_menu/appinfo/app.php”],“function”:“require_once”},{“file”:“/home/pnwhomesolutions/public_html/localhost/cloud/lib/private/legacy/OC_App.php”,“line”:155,“function”:“requireAppFile”,“class”:“OC_App”,“type”:“::”,“args”:[“side_menu”]},{“file”:“/home/pnwhomesolutions/public_html/localhost/cloud/lib/private/legacy/OC_App.php”,“line”:128,“function”:“loadApp”,“class”:“OC_App”,“type”:“::”,“args”:[“side_menu”]},{“file”:“/home/pnwhomesolutions/public_html/localhost/cloud/lib/base.php”,“line”:997,“function”:“loadApps”,“class”:“OC_App”,“type”:“::”,“args”:},{“file”:“/home/pnwhomesolutions/public_html/localhost/cloud/index.php”,“line”:37,“function”:“handleRequest”,“class”:“OC”,“type”:“::”,“args”:}],“File”:“/home/pnwhomesolutions/public_html/localhost/cloud/lib/public/AppFramework/App.php”,“Line”:84,“CustomMessage”:“–”},“userAgent”:“Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0”,“version”:“19.0.3.1”}

{“reqId”:“X2PE7IEvn9wRsMjtQTNwTwACiwk”,“level”:3,“time”:“2020-09-17T20:19:57+00:00”,“remoteAddr”:“76.121.102.127”,“user”:“oh84f1”,“app”:“unsplash”,“method”:“POST”,“url”:“/cloud/index.php/apps/mail/api/accounts”,“message”:{“Exception”:“RuntimeException”,“Message”:“App class OCA\Unsplash\AppInfo\Application is not setup via query() but directly”,“Code”:0,“Trace”:[{“file”:“/home/pnwhomesolutions/public_html/localhost/cloud/apps/unsplash/lib/AppInfo/Application.php”,“line”:27,“function”:“__construct”,“class”:“OCP\AppFramework\App”,“type”:“->”,“args”:[“unsplash”,]},{“file”:“/home/pnwhomesolutions/public_html/localhost/cloud/apps/unsplash/appinfo/app.php”,“line”:11,“function”:“__construct”,“class”:“OCA\Unsplash\AppInfo\Application”,“type”:“->”,“args”:},{“file”:“/home/pnwhomesolutions/public_html/localhost/cloud/lib/private/legacy/OC_App.php”,“line”:266,“args”:[“/home/pnwhomesolutions/public_html/localhost/cloud/apps/unsplash/appinfo/app.php”],“function”:“require_once”},{“file”:“/home/pnwhomesolutions/public_html/localhost/cloud/lib/private/legacy/OC_App.php”,“line”:155,“function”:“requireAppFile”,“class”:“OC_App”,“type”:“::”,“args”:[“unsplash”]},{“file”:“/home/pnwhomesolutions/public_html/localhost/cloud/lib/private/legacy/OC_App.php”,“line”:128,“function”:“loadApp”,“class”:“OC_App”,“type”:“::”,“args”:[“unsplash”]},{“file”:“/home/pnwhomesolutions/public_html/localhost/cloud/lib/base.php”,“line”:997,“function”:“loadApps”,“class”:“OC_App”,“type”:“::”,“args”:},{“file”:“/home/pnwhomesolutions/public_html/localhost/cloud/index.php”,“line”:37,“function”:“handleRequest”,“class”:“OC”,“type”:“::”,“args”:}],“File”:“/home/pnwhomesolutions/public_html/localhost/cloud/lib/public/AppFramework/App.php”,“Line”:84,“CustomMessage”:“–”},“userAgent”:“Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0”,“version”:“19.0.3.1”}

{“reqId”:“X2PE7IEvn9wRsMjtQTNwTwACiwk”,“level”:4,“time”:“2020-09-17T20:19:58+00:00”,“remoteAddr”:“76.121.102.127”,“user”:“oh84f1”,“app”:“mail”,“method”:“POST”,“url”:“/cloud/index.php/apps/mail/api/accounts”,“message”:“Creating account failed: Error connecting to SMTP server.”,“userAgent”:“Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0”,“version”:“19.0.3.1”}

*horde_imap.log: Thu, 17 Sep 2020 20:19:57 +0000

Connection to: imap://website.com:993/
Server connection took 0.3603 seconds.
S: * OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE NAMESPACE LITERAL+ AUTH=PLAIN AUTH=LOGIN] Dovecot ready.
C: 1 AUTHENTICATE PLAIN [INITIAL CLIENT RESPONSE (username: redacted)]
S: 1 OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY PREVIEW=FUZZY STATUS=SIZE NAMESPACE LITERAL+ NOTIFY SPECIAL-USE COMPRESS=DEFLATE QUOTA] Logged in
Command 1 took 0.0285 seconds.
C: 2 LOGOUT
S: * BYE Logging out
S: 2 OK Logout completed (0.001 + 0.000 secs).
Command 2 took 0.0005 seconds.

  • horde_smtp.log
    EMPTY

Any advice on how to get it working?

1 Like

In a first step I wouldn’t force any config.php related parameters.

Unfortunately essential information are missing from your description. Please start and describe IN DETAIL how the the IMAP and SMTP parameters have to look like to connect to the server (names, ports, settings, etc.) as you already did it with other apps.

Next, please describe IN DETAIL which parameters you’ve entered in the mail app configuration dialog and what the error message is if you confirm that settings. (You can e.g. provide a screenshot of the settings and the displayed error message).

BTW, are you aware, that you’re using a correct Let’s Encrypt certificate on port 993/tcp for your domain “usecarpro.com” (CN = usecarpro.com), but that you use a different certificate on port 587/tcp and on port 25/tcp (CN = *.prod.iad2.secureserver.net)?!

Additionally the server response on port 25/tcp is extremely slow (> 20 sec) compared to 587/tcp (< 2 sec) and 993/tcp (< 1 sec).

Thank you for your response! I attached a screenshot. With the godaddy shared hosting, prior to installing SSL, the instructions said to connect mail via prod.iad2.secureserver.net as the host. I am guessing this was for security purposes and might be a service from godaddy (unsure)? After installing SSL, the instructions it generated going forward said to connect via usecarpro.com.

Currently, I am able to connect and send/receive mail in ms outlook using either host with the same port settings and SSL selected as the encryption method (IMAP 993 / SMTP 465).

I was unaware that there is a different certificate installed on ports 587/25, what the implications of that are, or how I might change it.

Here are the settings as currently working in outlook (also see Nextcloud screenshot):

Incoming:
server: website.com (also works with secureserver address as host)
port: 993
Encryption: SSL/TLS
Require login using secure password authentication (SPA): Yes
Outgoing:
server: website.com (also works with secureserver address as host)
port: 465
Encryption: SSL/TLS
My outgoing (SMTP) server requires authentication: Use same settings as incoming mail server.

I have tried using both website.com and secureserver as host in nextcloud.

Ok, you’ve confirmed my assumption, that you’re using the same server for outgoing mail. Due to the fact that the certificate doesn’t match the server name you are using, that most likely causes the problem. BTW, the different certificate is also being used for port 465/tcp and the response on that port is also very slow.

I would recommend to get in touch with your hoster and clarify how you can configure a valid certificate for your outgoing server.

1 Like

Thanks for the help, I will reach out and see what they say. Is there a reason that this would only impact nextcloud and not any of the other mail applications?

It always depends on how other applications have been programmed. Do they allow a security downgrad to an unencrypted session, are they correctly checking the certificate chain, etc., etc.

I talked with godaddy on chat for about an hour and a half. It was
 unpleasant. They had me try a different port for their mail server (25) with and without SSL, and I still got the same error. Then they tried to sell me things. :man_facepalming:

@ChristophWurst have you ran into this one before?

Is this still in use? It would explain why the horde_smtp.log is empty. php-mail is only used in very specific environments and I guess you don’t need this.

So try without this option and check the SMTP logs again. I thouls contain something, hopefully.

Alright, I think I’ve stumbled upon a solution!

I reran the functions with debug log enabled, and the SMTP log now showed that the SMTP connection was timing out. In the other forum I read that contained the ‘mail_smtptimeout’ => 30, solution, it instructed to place the code in config.php. I noticed that the account setup was not actually waiting more than 5 seconds with the code placed in config.php. However, there is existing code for this contained in SmtpClientFactory.php in the line containing (‘app.mail.smtp.timeout’, 5).

When adjusting it to (‘app.mail.smtp.timeout’, 30) in SmtpClientFactory.php, the account creation was successful and I was able to load and send/receive mail.

3 Likes

@afarr33
Hi, I think I have the same prob.
I’ve created my account on next cloud and everything seem to go well (agenda, import file
) everything but the mail

I receive the same prob: some time passes and then I have an error telling that “there is an error and system cannot login” (or somethings similar) maybe it is the same error (a timeout
or similar
)

can you tell meow can I change the timeout? I’ve not seen anything where I can change that value


Thank you

Renato

This worked for me too!

Hi. How are you? I am new at Nextcloud. Can you help me with email setup on nextcloud? Its driving me crazy, I am doing an effort to solved it myself but I can’t. Please. Thanks in advance.

Please open a new topic.