How to configure Email and TLS

I’m trying to set up email using our account but it’s not working, I find this error in the internal logs:

[2015/08/25 14:43:33 UTC] [EROR] Email settings are not valid err=SendMail: Failed to open TLS connection, tls: first record does not look like a TLS handshake

[2015/08/25 14:48:26 UTC] [EROR] An error occured while sending an email in emailTeams err=SendMail: Failed to open TLS connection, tls: first record does not look like a TLS handshake
[2015/08/25 14:48:56 UTC] [EROR] /api/v1/teams/signup:SendMail code=500 rid=51w1r6ggd3rnbruf1dcakktctc uid= ip=192.168.177.171 Failed to open TLS connection [details: tls: first record does not look like a TLS handshake]

Any idea? I’m using the same configuration for other services

In the Mattermost config.json or docker_config.json file have you set “UseTLS”: true ?

@coreyhulen yes, if I set to false I have a BAD HELO error

If you’ve tried UseTLS=true you might try UseTLS=false and UseStartTLS=true, but there is a bug preventing UseStartTLS from working on 0.6 so you would need to try with a daily build or wait approx 1 week for 0.7.

For example we use TLS internally with Amazon SES, looks something like

SMTPServer": “email-smtp.us-east-1.amazonaws.com:465”,
“UseTLS”: true,
“UseStartTLS”: false,

I’ve tried but now I have this:
[2015/09/02 08:51:52 UTC] [EROR] Email settings are not valid err=CheckMailSettings: No email settings present, mail will not be sent,
and no clue on what is wrong,

  "EmailSettings": {
        "ByPassEmail" : true,
        "SMTPUsername": "trac-dev@xxx.com",
        "SMTPPassword": "xxx",
        "SMTPServer": "smtp.xxx.com:587",
        "UseTLS": false,
        "UseStartTLS": true,
        "FeedbackEmail": "trac-dev@xxx.com",
        "FeedbackName": "Mattermost",
        "ApplePushServer": "",
        "ApplePushCertPublic": "",
        "ApplePushCertPrivate": ""
    },

“ByPassEmail” : true, --> should be “ByPassEmail” : false,

Some more info about configuring email is located at
https://github.com/mattermost/platform/blob/master/doc/install/single-container-install.md#email-setup-optional

mmm, that’s embarassing, I’m sure I tried but maybe something else was not working so I return to that… @coreyhulen that worked so thanks. Now the problem is: TLS is not working still. I have to use StartTLS so I did but this is the log now:

 [2015/09/02 16:10:09 UTC] [EROR] An error occured while sending an email in emailTeams err=SendMail: Failed to add to email address, 554 5.7.1 : Helo command rejected: Bad HELO

Might be because of the authentication method? In my case it’s plain, don’t know if this might help.

Regarding the link you pasted, Email Setup seems replaced by Enable Email and the link about it is 404 (smtp-email-setup.md seems missing in master).

hmm…It looks like it auth’ed and connected successfully since it made it to https://github.com/mattermost/platform/blob/master/utils/mail.go#L131 but it looks like your email server is rejecting the TO email address.

what email service are you using? I would search for the error code “554 5.7.1” on that service.

“554 5.7.1 : Helo command rejected: Bad HELO” is the error Mattermost is recieving from the smtp server.

1 Like

According to http://serverfault.com/questions/269271/sendmail-helo-rejected-localhost-localdomain seems like the server reject me because I present myself as <localhost>. So the connection to the SMTP server is fine but the HELO while trying to send the email fails. How is that localhost set? I’ve find out it could be set here https://github.com/mattermost/platform/blob/master/utils/config.go#L241 but I’ll check better tomorrow also using wireshark because I didn’t noticed the error that should come if that code is triggered.

Thanks again, Cheers

@coreyhulen I’ve solved the issue so for the records here what happened:

The docker is presenting itself as <localhost> which is then rejected by our SMTP provider. I changed the SMTP to our relay, this fixed the problem as our server accept it using IP to make sure we are we. From my IT guy, localhost might be caused by a misconfiguration in postfix or maybe in the machine. He also told me that the emails coming from Mattermost do not have the mandatory Message-ID field set, this might be something that need to be fixed.

Thanks again for help, keep up with the good work!