# Additional settings Email configuration - SOLVED

**URL:** <https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070>\
**Category:** ℹ️ Support\
**Created:** [October 8, 2017, 1:58pm UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070 "2017-10-08T13:58:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonnie\_r](https://help.nextcloud.com/letter_avatar/jonnie_r/32/6_22734026db12803ebb3e059622ac3534.png) [@jonnie\_r](https://help.nextcloud.com/u/jonnie_r)\
**Post date:** [October 8, 2017, 1:58pm UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/1 "2017-10-08T13:58:16Z")

</div>

Hi,

I am trying to configure Nextcloud to use the EMail feature in additional settings, however it keeps returning the following error - A problem occurred while sending the email. Please revise your settings. (Error: Unable to connect with TLS encryption)

I know this isn’t the case as I can log in to the dedicated account using my email client, using IMAP and SMTP. My server requires STARTTLS and I connect on port 587. Not sure why Nextcloud won’t connect.

Jon

---

<div class="post-metadata">

**Author:** ![jonnie\_r](https://help.nextcloud.com/letter_avatar/jonnie_r/32/6_22734026db12803ebb3e059622ac3534.png) [@jonnie\_r](https://help.nextcloud.com/u/jonnie_r)\
**Post date:** [October 9, 2017, 8:14am UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/3 "2017-10-09T08:14:05Z")

</div>

The GitHub issue seems to be related to the Mail app, not the functionality built in to Nextcloud for password reset etc., are both issues linked?

I don’t have the mail app installed as according to this page [https://docs.nextcloud.com/server/12/admin\_manual/configuration\_server/email\_configuration.html](https://docs.nextcloud.com/server/12/admin_manual/configuration_server/email_configuration.html) Nextcloud has basic functionality built in to connect to my SMTP server.

I am running the latest stable, v12.0.3

---

<div class="post-metadata">

**Author:** ![JimmyKater](https://help.nextcloud.com/user_avatar/help.nextcloud.com/jimmykater/32/4850_2.png) [@JimmyKater](https://help.nextcloud.com/u/JimmyKater)\
**Post date:** [October 9, 2017, 8:26am UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/4 "2017-10-09T08:26:00Z")

</div>

needed informations are missing, still. sorry.  
pls install app “issue template” - fill in missing infos there and copy&paste it’s output here.

---

<div class="post-metadata">

**Author:** ![joergschulz](https://help.nextcloud.com/user_avatar/help.nextcloud.com/joergschulz/32/55349_2.png) [@joergschulz](https://help.nextcloud.com/u/joergschulz)\
**Post date:** [October 9, 2017, 10:08am UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/5 "2017-10-09T10:08:03Z")

</div>

sorry, misunderstood your request, post withdrawn.

---

<div class="post-metadata">

**Author:** ![jonnie\_r](https://help.nextcloud.com/letter_avatar/jonnie_r/32/6_22734026db12803ebb3e059622ac3534.png) [@jonnie\_r](https://help.nextcloud.com/u/jonnie_r)\
**Post date:** [October 22, 2017, 12:39pm UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/6 "2017-10-22T12:39:40Z")

</div>

Problem solved. It was because I use a self signed certificate on my mail server. Add options to StreamBuffer.php in the 3rdParty/Swiftmailer directory and all sorted now.

---

<div class="post-metadata">

**Author:** ![nikola.bogicevic](https://help.nextcloud.com/letter_avatar/nikola.bogicevic/32/6_22734026db12803ebb3e059622ac3534.png) [@nikola.bogicevic](https://help.nextcloud.com/u/nikola.bogicevic)\
**Post date:** [March 26, 2018, 11:43am UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/7 "2018-03-26T11:43:03Z")

</div>

I have a same problem.  
How to change StreamBuffer.php

I found some post on internet in which it is described to add

> Blockquote

$transport = Swift\_SmtpTransport::newInstance(‘[fqdn.mailserver.com](http://fqdn.mailserver.com)’, 587, ‘tls’)  
-\>setUsername(‘user’)  
-\>setPassword(‘Password’)  
-\>setStreamOptions(array(‘ssl’ =\> array(‘allow\_self\_signed’ =\> true, ‘verify\_peer’ =\> false)));

> Blockquote

/var/www/nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php

I changed and i don’t have eror (Error: Unable to connect with TLS encryption), but when i want to send a test email, test is in sending process and still waiting.

---

<div class="post-metadata">

**Author:** ![rubo77](https://help.nextcloud.com/user_avatar/help.nextcloud.com/rubo77/32/10341_2.png) [@rubo77](https://help.nextcloud.com/u/rubo77)\
**Post date:** [August 16, 2018, 4:07am UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/8 "2018-08-16T04:07:06Z")

</div>

could you please add some more information, how you changed it?

---

<div class="post-metadata">

**Author:** ![Chialya](https://help.nextcloud.com/letter_avatar/chialya/32/6_22734026db12803ebb3e059622ac3534.png) [@Chialya](https://help.nextcloud.com/u/Chialya)\
**Post date:** [September 23, 2018, 10:53am UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/9 "2018-09-23T10:53:46Z")

</div>

Hi, I’ve NC14 now and the same Problem with my own Mail-Server.  
The security is all right and I also have DANE-Support !  
But I have an self-signed Mail-Server certificate, which is OK with the right TLSA-Record!  
In NC this is not supportet. In an “all-self-hostet system” might this be a fault.

I’ve researched and modify line 263 in file:  
/var/www/nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php

$this-\>stream = @stream\_socket\_client($host.’:’.$this-\>params[‘port’], $errno, $errstr, $timeout, STREAM\_CLIENT\_CONNECT, **stream\_context\_create(array(‘ssl’=\>[‘verify\_peer’=\>false, ‘verify\_peer\_name’=\>false, ‘allow\_self\_signed’=\>true]))**);

Now I can send mails with my own mail-server with self-signed certificates over TLS !

I think on an nextcloud update, it will be resettet.

chears

---

<div class="post-metadata">

**Author:** ![JimmyKater](https://help.nextcloud.com/user_avatar/help.nextcloud.com/jimmykater/32/4850_2.png) [@JimmyKater](https://help.nextcloud.com/u/JimmyKater)\
**Post date:** [September 24, 2018, 9:43am UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/10 "2018-09-24T09:43:45Z")

</div>

> [@Chialya](#):
>
> I think on an nextcloud update, it will be resettet.

unless you won’t file an issue about this on github (and having it solved) it sure enough will be reset by next update

---

<div class="post-metadata">

**Author:** ![Chialya](https://help.nextcloud.com/letter_avatar/chialya/32/6_22734026db12803ebb3e059622ac3534.png) [@Chialya](https://help.nextcloud.com/u/Chialya)\
**Post date:** [September 24, 2018, 10:40am UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/11 "2018-09-24T10:40:29Z")

</div>

no, there is no problem in the program.  
I lower the security level with this setting! Because all certificates are accepted and no CA is checked. Especially since the switch exists, it only has to be adjusted.

The right way would be:

1. store the serial number of my self-signed mailserver-certificate in NC.  
or better:
2. add my own CA-cert to the list of accepted CA authorities.  
or best:
3. NC is able to check valid self-signed certificates using the TLSA record in the DNS.

---

<div class="post-metadata">

**Author:** ![JimmyKater](https://help.nextcloud.com/user_avatar/help.nextcloud.com/jimmykater/32/4850_2.png) [@JimmyKater](https://help.nextcloud.com/u/JimmyKater)\
**Post date:** [September 24, 2018, 10:42am UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/12 "2018-09-24T10:42:57Z")

</div>

> [@Chialya](#):
>
> I lower the security level with this setting!

this could be regarded as a problem 😉 prolly it’s unwanted to the devs.  
but i see your point to NOT file an isse on github. which means: next update → all gone

---

<div class="post-metadata">

**Author:** ![Chialya](https://help.nextcloud.com/letter_avatar/chialya/32/6_22734026db12803ebb3e059622ac3534.png) [@Chialya](https://help.nextcloud.com/u/Chialya)\
**Post date:** [September 24, 2018, 11:06am UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/13 "2018-09-24T11:06:19Z")

</div>

> [@JimmyKater](#):
>
> but i see your point to NOT file an isse on github. which means: next update –\> all gone

What do you mean by that?  
I know for myself that it will be lost. That is exactly what I said myself before. So what are you trying to tell me?

---

<div class="post-metadata">

**Author:** ![JimmyKater](https://help.nextcloud.com/user_avatar/help.nextcloud.com/jimmykater/32/4850_2.png) [@JimmyKater](https://help.nextcloud.com/u/JimmyKater)\
**Post date:** [September 24, 2018, 11:08am UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/14 "2018-09-24T11:08:54Z")

</div>

> [@Chialya](#):
>
> So what are you trying to tell me?

i was just trying to tell you that your anticipation

> [@Chialya](#):
>
> I think on an nextcloud update, it will be resettet.

would be correct. nothing more.

cheerio  
jimmy

---

<div class="post-metadata">

**Author:** ![samtuke](https://help.nextcloud.com/user_avatar/help.nextcloud.com/samtuke/32/21263_2.png) [@samtuke](https://help.nextcloud.com/u/samtuke)\
**Post date:** [February 11, 2020, 7:29pm UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/15 "2020-02-11T19:29:33Z")

</div>

I confirm that this is still an issue on Nextcloud17.0.2, and that this workaround still works, and that it would be nice to see this included as a setting in Core 🙂

---

<div class="post-metadata">

**Author:** ![JimmyKater](https://help.nextcloud.com/user_avatar/help.nextcloud.com/jimmykater/32/4850_2.png) [@JimmyKater](https://help.nextcloud.com/u/JimmyKater)\
**Post date:** [February 11, 2020, 9:41pm UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/16 "2020-02-11T21:41:54Z")

</div>

> [@samtuke](#):
>
> and that it would be nice to see this included as a setting in Core

no github-issue filed, no solution 😉

---

<div class="post-metadata">

**Author:** ![Buddster124](https://help.nextcloud.com/user_avatar/help.nextcloud.com/buddster124/32/27498_2.png) [@Buddster124](https://help.nextcloud.com/u/Buddster124)\
**Post date:** [July 27, 2020, 10:02pm UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/17 "2020-07-27T22:02:35Z")

</div>

On Nextcloud Version 19.0.1 The solution is to add this to your `config.php` file.

```
"mail_smtpstreamoptions" => array(
'ssl' => array(
    'allow_self_signed' => true,
    'verify_peer' => false,
    'verify_peer_name' => false
  )
),

```

This solved the problem for me.

---

<div class="post-metadata">

**Author:** ![Peter\_Carlsson](https://help.nextcloud.com/user_avatar/help.nextcloud.com/peter_carlsson/32/28557_2.png) [@Peter\_Carlsson](https://help.nextcloud.com/u/Peter_Carlsson)\
**Post date:** [September 1, 2020, 2:50am UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/18 "2020-09-01T02:50:26Z")

</div>

This fix works for 19.0.2 as well.

---

<div class="post-metadata">

**Author:** ![twinkybot](https://help.nextcloud.com/user_avatar/help.nextcloud.com/twinkybot/32/7658_2.png) [@twinkybot](https://help.nextcloud.com/u/twinkybot)\
**Post date:** [November 21, 2020, 4:34pm UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/19 "2020-11-21T16:34:25Z")

</div>

Thanks, your configuration helped, also for Nextcloud 20!

---

<div class="post-metadata">

**Author:** ![manilaboy1vic](https://help.nextcloud.com/letter_avatar/manilaboy1vic/32/6_22734026db12803ebb3e059622ac3534.png) [@manilaboy1vic](https://help.nextcloud.com/u/manilaboy1vic)\
**Post date:** [February 1, 2021, 8:38am UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/20 "2021-02-01T08:38:09Z")

</div>

This worked for me. Thank you so much…

Version: **20.0.6**

in config.php:

“mail\_smtpstreamoptions” =\> array(  
‘ssl’ =\> array(  
‘allow\_self\_signed’ =\> true,  
‘verify\_peer’ =\> false,  
‘verify\_peer\_name’ =\> false  
)  
),

---

<div class="post-metadata">

**Author:** ![rhysers](https://help.nextcloud.com/letter_avatar/rhysers/32/6_22734026db12803ebb3e059622ac3534.png) [@rhysers](https://help.nextcloud.com/u/rhysers)\
**Post date:** [February 3, 2021, 7:49am UTC](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070/21 "2021-02-03T07:49:23Z")

</div>

Is there a way to get more detailed errors? I already know I’m doing weird things, so I’m not sure exactly where its going wrong. I did the above, but when I try to connect to 127.0.0.1 I get the generic “Could not open secure TLS connection to the IMAP server.”  
Im using socat to forward 127.0.0.1:1144 to remote host 192.168.136.138 which forwards that to a service listening on 127.0.0.1:1143 on that host (not my nextcloud instance). I can connect with telnet. Just trying to get more info. Enabling Debug logging didn’t give me any more info.

(Edit for clarity)

[Next page](https://help.nextcloud.com/t/additional-settings-email-configuration-solved/22070.md?page=2)
