Mattermost-server: SMTP not working

Created on 20 Jun 2019  路  19Comments  路  Source: mattermost/mattermost-server

Summary

I deployed mattermost in a docker container on an Ubuntu 18.04 machine. When I enter my SMTP credentials and test the connection, it doesn't connect to the SMTP server and it doesn't send mail.

Steps to reproduce

  1. Deploy Mattermost in a docker container using docker-compose on a fresh Ubuntu 18.04 machine following this guide: https://docs.mattermost.com/install/prod-docker.html
    Version:
    Mattermost Enterprise Edition
    Mattermost Version: 5.12.0
    Database Schema Version: 5.12.0
    Database: postgres

  2. Open the system-console from Browser (Google Chrome)

  3. Go to SMTP Settings and fill in the FQDN, Port 465, enable authentication, fill in username and password, click in SAVE and Test connection

Expected behavior

It should connect to the SMTP Server and send a test mail.

Observed behavior (that appears unintentional)

The connection test runs forever. When switching to Port 25, it says: "Connection unsuccessful: Connection unsuccessful: SendMail: Failed to authenticate on SMTP server, unencrypted connection - undefined"

When using Port 465, Logs say:
{"level":"error","ts":1561064866.4216301,"caller":"mailservice/mail.go:134","msg":"Failed to open a connection to SMTP server EOF"}
{"level":"error","ts":1561064866.42187,"caller":"mlog/log.go:172","msg":"Connection unsuccessful: SendMail: Failed to open TLS connection, EOF","path":"/api/v4/email/test","request_id":"nfpnbxsp4ir4ppu1zrmqkjhu9e","ip_addr":"1.2.3.4","user_id":"sbuj48gghibjidj5eqjeixpj1o","method":"POST","err_where":"testEmail","http_code":500,"err_details":""}

Bug ReporOpen

All 19 comments

Of course I tried that with different SMTP Servers which are definitely working and I double-checked the credentials. Also tried port 587, same behavior

Hi @mcp11, thank you for the report. Would you be open to posting this issue on our docker repo and our docker maintainers will take a look: https://github.com/mattermost/mattermost-docker/issues?

I'm testing v5.12 on my Mac make from source, got the same error.
OS: macOS Mojave 10.14.5
Server and Webapp: release 5.12

make run-server 

Hi @mcp11, thank you for the report. Would you be open to posting this issue on our docker repo and our docker maintainers will take a look: https://github.com/mattermost/mattermost-docker/issues?

Hi @amyblais, I created an issue on your docker repo: https://github.com/mattermost/mattermost-docker/issues/398
Should I delete the issue here?

Hi all, would you be open to sharing your config settings related to SMTP?

(I'm answering on this issue because there are more people here)

It seems that you cannot reach at all the SMTP server, can you provide your SMTP configure (with obfuscated credentials of course) please ?

Can you post also this part of the settings of the config.json?

The emailsettings part

Thanks

Got the same issue.
The UI does not display the Connection Security option.
I had to set "ConnectionSecurity": "", to "ConnectionSecurity": "TLS", in /opt/mattermost/config/config.json for it to work.

Server version is 5.12

Hi @hmenzagh, I think your issue is different, I opened a ticket for it here as I was able to reproduce on a team edition server: https://mattermost.atlassian.net/browse/MM-16627.

Testing on Debian, tried TLS and also STARTTLS directly with the config. Nothing helped.

tls: first record does not look like a TLS handshake

I'm running UNMS on the same host and SMTP (Exchange) works well, only Mattermost won't.

Hi all, following up on this. Would you be open to sharing your config settings related to SMTP and email?

Sure! But I'm really confused now. Haven't change anything, only again TLS to STARTTLS - now it works. No idea why. I just tried it again to copy the error message for TLS and STARTTLS.

"http_code":500,"err_details":"err=Fehler beim 脰ffnen der TLS Verbindung"

        "EnableSMTPAuth": true,
        "SMTPUsername": "[email protected]",
        "SMTPPassword": "password",
        "SMTPServer": "ex2.mail.ovh.net",
        "SMTPPort": "587",
        "ConnectionSecurity": "TLS",

Works: "ConnectionSecurity": "STARTTLS",

Can't reproduce tls: first record does not look like a TLS handshake

Using in other apps always TLS without any problems.

Hi @Xairoo, do you mean it works with STARTTLS, but it doesn't work with TLS?

@mcp11 @hotlong Please let me know if you have any updates on this?

https://mattermost.atlassian.net/browse/MM-16627 is fixed in v5.13 and we haven't received any feedback for a while, so I'll close this issue for now. Please re-open this issue with additional information for troubleshooting if the problem persists.

Got the same issue.
The UI does not display the Connection Security option.
I had to set "ConnectionSecurity": "", to "ConnectionSecurity": "TLS", in /opt/mattermost/config/config.json for it to work.

Server version is 5.12

UI still does not update the config on server v5.13.0.

Setting environment variable MM_EMAILSETTINGS_CONNECTIONSECURITY also helps.

Hi @developweekly, would you be able to share your SMTP settings as well as email settings?

   "EmailSettings": {
        "EnableSignUpWithEmail": true,
        "EnableSignInWithEmail": true,
        "EnableSignInWithUsername": true,
        "SendEmailNotifications": true,
        "UseChannelInEmailNotifications": false,
        "RequireEmailVerification": true,
        "FeedbackName": "mattermost",
        "FeedbackEmail": "***@***.com.tr",
        "ReplyToAddress": "***@***.com.tr",
        "FeedbackOrganization": "mattermost",
        "EnableSMTPAuth": true,
        "SMTPUsername": "***@***.com.tr",
        "SMTPPassword": "***",
        "SMTPServer": "smtp.yandex.com.tr",
        "SMTPPort": "465",
        "ConnectionSecurity": "STARTTLS",
        "SendPushNotifications": true,
        "PushNotificationServer": "https://push-test.mattermost.com",
        "PushNotificationContents": "generic",
        "EnableEmailBatching": false,
        "EmailBatchingBufferSize": 256,
        "EmailBatchingInterval": 30,
        "EnablePreviewModeBanner": false,
        "SkipServerCertificateVerification": false,
        "EmailNotificationContentsType": "full",
        "LoginButtonColor": "#0000",
        "LoginButtonBorderColor": "#2389D7",
        "LoginButtonTextColor": "#2389D7"
    },

The problem is although ConnectionSecurity is set as TLS from the UI, config remains as STARTTLS. STARTTLS option probably works for gmail etc, but not for yandex. I could only connect when I set environment variable MM_EMAILSETTINGS_CONNECTIONSECURITY=TLS. With the env var set, everything works as expected since UI is out of equation (This setting has been set through an environment variable. It cannot be changed through the System Console.).

@developweekly It appears that this issue could be related to the ConnectionSecurity setting getting switched when set in the UI, which is fixed in v5.14: https://mattermost.atlassian.net/browse/MM-17393.

Closing as the above ticket is fixed. Please re-open this issue if upgrading to v5.14 doesn't resolve the problem.

Was this page helpful?
0 / 5 - 0 ratings