Email Server Problem

Nextcloud 13.0.1
Ubuntu 16.04.4 LTS
Apache 2.4.18
PHP 7.2

Email Server doesn’t work. I’ve tried for months to get it to work. I understand that there’s no mail server included by default, but I’m trying to use the external one provided by my email host. I found in a different conversation to add the smtpdebug line and it doesn’t add anything to the log. Nothing at all.

The only clues I have to go on are two errors that the Settings page in the web GUI gives me:

  1. A problem occurred while sending the email. Please revise your settings. (Error: Connection could not be established with host sub4.mail.dreamhost.com [ #0])

It’s an external mail server administered by a hosting provider, I’ve tested it, I’m confident that it’s good.

  1. Invalid SMTP password.

I’ve intentionally kept it alphanumeric (no symbols) for testing purposes and it still throws that error, sometimes.

config.php:

  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_from_address' => 'user',
  'mail_domain' => 'my.domain',
  'maintenance' => false,
  'theme' => '',
  'mail_smtphost' => 'sub4.mail.dreamhost.com',
  'mail_smtpauth' => 1,
  'mail_smtpsecure' => 'ssl',
  'mail_smtpname' => 'user@my.domain',
  'mail_smtppassword' => 'password',
  'updater.release.channel' => 'stable',
  'mail_smtpport' => '465',
  'mail_smtpdebug' => true,

Do you have SSH access to the server? Can you connect to port 465 on the SMTP server? Also, do any of the other methods work, like PHP or Sendmail?

I’m able to connect to the mail server via all other non-Nextcloud clients that I’ve tried with the exact same settings.

I should note that the inability to connect from the Nextcloud settings also extends to the Nextcloud Mail app: “Error connecting to SMTP server” where it isn’t an option to use PHP or Sendmail.

yourcloudasia meant: can you access mail server from the nextcloud? The fact that it works from other hosts with the same settings but from different places is only the half way to go. You should finalize this with checking if your Nextcloud has the required ports open behind firewalls. In most cases servers are set in DMZ areas, seperated from internal nets with different rule-sets.

In some cases it helps to switch from SSL to STARTTLS here. maybe you give this a try.

I hadn’t even thought about it being a port issue. Using this solution, I was able to verify that my Nextcloud server was able to connect to and get the SSL certificate from the mail server.

Unless I’m missing something, it’s not a firewall or port issue.

i think

Invalid SMTP password.

means that there was (at least some kind of) a connection. to interactively “talk” to the mailserver you can also use telnet (for port 25) or openssl s_client for encrypted connections - this ususally produces more useful debugging output
https://duckduckgo.com/?q=telnet+smtp+commands
or
openssl s_client -connect sub4.mail.dreamhost.com:465
also, if
'mail_smtpname' => 'user@my.domain',
is not a dummy value it might be the reason for the error.
GOOD LUCK!

openssel s_client -connect sub4.mail.dreamhost.com:465 was the exact thing I did in my prior comment. It connected just fine. I didn’t see anything that might be debug-able, but I’ll do it again and check just in case.

As for the user@my.domain part, yes, I swapped this out in the original post and is not the error.

Status: Still need help.

Update: I’ve tried connecting to a few other email accounts, I’ve tried connecting directly from the server, and making sure that my account credentials aren’t symantically messing with Nextcloud. What I’ve read about Nextcloud is that the SMTP email method should be plug & play in the sense that it shouldn’t need anything additional installed in order to send basic emails like password resets. Regardless of the outgoing account credentials, the server works, the accounts work, and the Nextcloud client isn’t.

I’m not unwilling to try the PHP option, but I don’t feel like I’ve exhausted potential solutions to the SMTP option, and I really don’t want to get into Sendmail & scripting and all that mess to send some emails.

Thanks everyone for trying to help!

I am sorry with working ports on your server it’s hard to guess now. And I assume you’ve checked all SSL/STARTTLS options in Nextcloud already, right? Maybe it’s time to contact your ISP Mailserver Provider?

once you’re connected you can start feeding the server (e)smtp-commands (eg.

EHLO user@my.domain

and see how it reacts. look up the exact syntax. often the SSL/TLS/auth-params or the user/@domain-part are the reason for problems. and you could just ask your hoster how to configure this.
i tried this with openssl s_client (the lines starting with the number are the server’s “answers” with the ESMTP-statuscodes):
`…
220 homiemail-a35.g.dreamhost.com ESMTP
EHLO user@example.com

250-homiemail-a35.g.dreamhost.com
250-PIPELINING
250-SIZE 40960000
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250 8BITMIME
AUTH
501 5.5.4 Syntax: AUTH mechanism
AUTH PLAIN
334
QUIT
DONE
`
maybe you can go on from there.
GOOD LUCK!

O.K. You said, that you can connect with other MUAs or application to your mailserver on port 465, right?

What kind of auth does this mailserver supports? plain? cram?

BTW, have you swaks installed/availiable on this host? Then you can perform a connection test:

swaks --to django@mailserver.guru --from <--YOUR-WELL-KNOWN-ACCOUNT@YOUR-DOMAIN.TLD--> --auth LOGIN --auth-user <--YOUR-WELL-KNOWN-ACCOUNT@YOUR-DOMAIN.TLD--> --header-X-Test "Test-eMail" --server 69.163.253.135 --protocol SSMTP --header "Subject: $DATE testmail on port 465"

Set this <--YOUR-WELL-KNOWN-ACCOUNT@YOUR-DOMAIN.TLD--> to your personal datas.

Maybe you are hit by https://github.com/nextcloud/mail/issues/538?

My result was nearly identical to yours, @pete.dawgg.

220 homiemail-a97.g.dreamhost.com ESMTP
250-homiemail-a97.g.dreamhost.com
250-PIPELINING
250-SIZE 40960000
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250 8BITMIME
AUTH
501 5.5.4 Syntax: AUTH mechanism
AUTH PLAIN
334 
QUIT
DONE

From this, I decided to change 'mail_smtpauthtype' => 'LOGIN' to plain, and it didn’t help. I read up about a few of the other things listed, but I didn’t understand them.

@himbeere: Down near the bottom of that thread, someone said setting ‘app.mail.smtp.timeout’ => 20, resolved it for them. I tested this and it did not solve my issue. The error is still that a connection could not be established with sub4.mail.dreamhost.com.

Have you tried connecting to a different server, to see if Nextcloud or the mail server is the problem? Have you tried contacting the ISP, to find out if there is any reason why this wouldn’t work? Also, have you tried plain SMTP, or the PHP/Sendmail options?

well, you have to go on from there (this is just the most basic, simple connection) to find possible errors. look up the smtp-commands and use them to talk to the server on the cmdline (eg http://www.serversmtp.com/en/smtp-commands )
it probably wouldn’t hurt to ask your provider about this, too.
GOOD LUCK!

Have you tried to access your mailserver via swaks as I sugested here: Email Server Problem

Or did’nt you have a ahell-access on your nextcloud-server?