Email Service don't work correctly

Hello,
i got one problem with my Mail settings for my nexcloud server.
The problem is that nextcloud don’t want to send emails like password recovery etc. but when i test the email settings it says “It Works”

and the Test Email from Nextcloud arrived correctly.
So I don’t understand why only the Test Email arrived and the other emails like Passwordrecorvy for example not. I tested to send the passwordrecovery email to the same thats send the emails and thats works correctly.

Nextcloud Vversion: 15
Linuxversion: Ubuntu 18.04.1 LTS‬
Apache Version:
Server version: Apache/2.4.29 (Ubuntu)
Server built: 2018-10-10T18:59:25
PHP Version: 7.2.

my config.php are this

‘mail_from_address’ => ‘noreply’,
‘mail_smtpmode’ => ‘sendmail’,
‘mail_sendmailmode’ => ‘smtp’,
‘mail_domain’ => ‘example.com’,
‘mail_smtphost’ => ‘mail.example.com’,
‘mail_smtpauthtype’ => ‘LOGIN’,
‘mail_smtpdebug’ => true,
‘mail_smtpauth’ => 1,
‘mail_smtpname’ => ‘noreply@example.com’,
‘mail_smtppassword’ => ‘Placeholder’,
‘mail_smtpport’ => ‘465’,
‘mail_smtptimeout’ => 30,
‘mail_smtpsecure’ => ‘ssl’,

For the email server i use Plesk on the same machine as nextcloud is.
I can Login with other Programms on my Email and sending/receiving works as well.

I hope you can help me and cheers

PS. Sorry for my bad english

EDIT: I don’t know if this is important but my domain is hosted by cloudflare.

I hat some problems with my email settings, I could solve them by removing all mail_ entries in the config and reconfigured them by the web menu.

I reconfigured it but now i got the ERROR Code:
Beim Senden der E-Mail ist ein Problem aufgetreten. Bitte überprüfe Deine Einstellungen. (Fehler: Connection could not be established with host 127.0.0.1 [ #0])

‘mail_smtpmode’ => ‘smtp’,
‘mail_sendmailmode’ => ‘smtp’,
‘mail_from_address’ => ‘noreply’,
‘mail_domain’ => ‘example.com’,
‘mail_smtpauthtype’ => ‘LOGIN’,
‘mail_smtpauth’ => 1,
‘mail_smtphost’ => ‘127.0.0.1’,
‘mail_smtpport’ => ‘465’,
‘mail_smtpsecure’ => ‘ssl’,
‘mail_smtpname’ => ‘noreply@example.com’,
‘mail_smtppassword’ => ‘PLACEHOLDER’,

But i think that nextcloud cant communicate right with the mail server, because i tested it with a mail server that i bought and that run smothly. But only Nexcloud can’t connect right to my own mail server. The Email Addon from Nextcloud to manage emails works well with the same configurations. So i am a bit confused

Hi all,

I am experiencing similar problems. Nextcloud can’t establish a connection to my mail server - in fact, any mail server. I tested it with my personal one, gmail and others.

Nextcloud: 15.0.0 (problem also appeared on 14.0.4, hence trying to solve it by updating to 15.0.0)
PHP: 7.2
Apache Version (couldn’t find out)

‘mail_smtpdebug’ => true,
‘mail_from_address’ => ‘ADDRESS’,
‘mail_smtpmode’ => ‘smtp’,
‘mail_domain’ => ‘DOMAIN.de’,
‘mail_smtpsecure’ => ‘ssl’,
‘mail_smtpauth’ => 1,
‘mail_smtpport’ => ‘25’,
‘mail_smtpname’ => ‘USERNAME’,
‘mail_smtppassword’ => ‘PLACEHOLDER’,
‘mail_smtpauthtype’ => ‘LOGIN’,
‘mail_smtphost’ => ‘SERVER’,
‘mail_sendmailmode’ => ‘smtp’,

I’ve enabled the debug mode, and it’s telling me:

Connection could not be established with host SERVER [ #0] Log data: ++ Starting Swift_SmtpTransport !! Connection could not be established with host SERVER [ #0] (code: 0)

I have no idea what to do. Please help.

All the best,
Jonas

In my case I used the actual name of the mail server like mail.mydomain.de instead of 127.0.0.1 or localhost. That works for me.

i tried both. Both Work with email client that runs on the same machine but nextcloud say to both that he cant connect. it doesnt matter which adress i tried nextcloud said to both that it can’t connect

Hello,
Maybe I’ll say something stupid, in advance sorry in case.
Is it possible that there is a restriction in the access-sending of mail in the configuration of your domain name provider?
I hope you can solve your problem quickly :crossed_fingers:

FYI, in my case, I just have the following lines:

  'mail_from_address' => 'xxxx',
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_domain' => 'yyyy.zzz',
  'mail_smtpsecure' => 'ssl',
  'mail_smtphost' => '_name of the outgoing server_',
  'mail_smtpport' => '465',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'xxxx@yyy.zzz',
  'mail_smtppassword' => '_your password_',

Hello @JonasF ,
Is it normal that you specify port 25 in ssl?
Maybe it’ll help you :grinning:

Hi @ffs69,

Thank you for the suggestion! Unfortunately, removing the port doesn’t do anything. As far as I am aware, I need to specify port 25 when using SSL/TLS - is that not so? At least that was the case for my email clients…

Any other suggestions?

Thanks again and all the best,
Jonas

For SSL/TSL you need port 465

1 Like

@Hamm3rhart, thank you! What I didn’t realise that nextcloud was solely using ssl (which is what you meant, @ffs69?). My email client has a similar setting called SSL/TLS but is apparently using TLS when specifying port 25, unlike nextcloud. I’m now using STARTTLS - am I correct in assuming it is the more up-to-date protocol?

Thanks again!
All the best,
Jonas

You can choose the configuration but you have to put the same thing on both sides:

https://docs.nextcloud.com/server/15/admin_manual/configuration_server/config_sample_php_parameters.html#mail-parameters

'mail_smtpsecure' => '',

This depends on mail_smtpmode. Specify when you are using ssl or tls, or leave empty for no encryption.
Defaults to '' (empty string)

'mail_smtpport' => 25,

This depends on mail_smtpmode. Specify the port for sending mail.
Defaults to 25

I do not know if it’s still accurate, but there can be different ports configured: 25, 465, 587, 2525.
https://www.mailgun.com/blog/which-smtp-port-understanding-ports-25-465-587

@JonasF https://www.fastmail.com/help/technical/ssltlsstarttls.html read this

1 Like

Look at this link

This solved my problem, there is outgoing blocking default ports on some droplets

1 Like

Hello,

To test your connection, try to go to CMD and type :
telnet smtp.yourdomain.com 25

1 Like

This thread is two years old. :wink:

Beside of that, you normally do not need port 25 in order to connect to an SMTP server. Most SMTP servers use 465 (SSL) or 587 (STARTTLS) for clients to connect. Port 25 is only needed, if you want to send mails directly from your server to the receiving mail server, without using an external SMTP server. But that’s a bad idea, because most mail servers will reject mails coming from servers without proper PTR, SPF and DKIM records, or at least flag them as spam. So unless your Nextcloud server is also a fully fledged email server, you don’t need port 25.

1 Like