Can't send email

Summary

can’t send email

Steps to reproduce

  • mattermost version 5.19.0
  • CentOS 7

I constructed according to

Expected behavior

Mail server can’t receive SMTP certification information.

Observed behavior

mattermost.log is

{
	"level": "error",
	"ts": 1588838428.2882004,
	"caller": "mlog/log.go:174",
	"msg": "Connection unsuccessful: SendMail: Failed to authenticate on SMTP server, unencrypted connection",
	"path": "/api/v4/email/test",
	"request_id": "xxxxxxxxxxxxxxxxxxxxx",
	"ip_addr": "xxx.xxx.xxx.xxx",
	"user_id": "xxxxxxxxxxxxxxxxxxxxx",
	"method": "POST",
	"err_where": "testEmail",
	"http_code": 500,
	"err_details": ""
}

The configurations ares as follows.

    "EmailSettings": {
        "EnableSignUpWithEmail": true,
        "EnableSignInWithEmail": true,
        "EnableSignInWithUsername": true,
        "SendEmailNotifications": true,
        "UseChannelInEmailNotifications": false,
        "RequireEmailVerification": true,
        "FeedbackName": "mattermost-admin",
        "FeedbackEmail": "xxx@xxx",
        "ReplyToAddress": "xxx@xxx",
        "FeedbackOrganization": "",
        "EnableSMTPAuth": true,
        "SMTPUsername": "xxx@xxx",
        "SMTPPassword": "xxx",
        "SMTPServer": "xxx.xxx.xxx.xxx",
        "SMTPPort": "xxx",
        "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"
    },

Authentication of Mail server is plaintext.

I tried 6 patterns.

  1. Enable SMTP Authentication: true
    Connection Security: None
    →Error
    Connection unsuccessful: Connection unsuccessful: SendMail: Failed to authenticate on SMTP server, unencrypted connection

  2. Enable SMTP Authentication: true
    Connection Security: TLS
    →Error
    Connection unsuccessful: Connection unsuccessful: SendMail: Failed to open TLS connection, tls: first record does not look like a TLS handshake

  3. Enable SMTP Authentication: true
    Connection Security: STARTTLS
    →Error
    Connection unsuccessful: Connection unsuccessful: SendMail: Failed to authenticate on SMTP server, unencrypted connection

  4. Enable SMTP Authentication: false
    Connection Security: None
    →Success. But Mail Server is not receive SMTP certification information. ID and password are nothing.

  5. Enable SMTP Authentication: false
    Connection Security: TLS
    →Error
    Connection unsuccessful: Connection unsuccessful: SendMail: Failed to open TLS connection, tls: first record does not look like a TLS handshake

  6. Enable SMTP Authentication: false
    Connection Security: STARTTLS
    →Success. But Mail Server is not receive SMTP certification information. ID and password are nothing.

Hello, @maki

Based on the error that we are seeing in mattermost.log, the server is complaining about unencrypted connection:

Can you please confirm which SMTP setting you are using based on the sample configuration we shared in the documentation?

We will then cross check it with the right SMTP connection security (None / TLS / STARTTLS), port, and SMTP server before we dig deeper into the respective error.

For additional context, I am also troubleshooting another issue here related to the first record does not look like a TLS handshake error:

@ahmaddanial
Thanks you the reply.

Can you please confirm which SMTP setting you are using based on the configuration we shared in the documentation?

Mail server constructed internally. None of sample case apply.

Mail domain is company original domain and port is original port not default port.

Authentication of Mail server is plaintext, so I think SMTP connection security is “None”.

I’m sorry for my poor English.

Hello, Maki.

Thank you for the clarification. This explains why the log is complaining about Connection unsuccessful: SendMail: Failed to authenticate on SMTP server, unencrypted connection:

Since this is a custom SMTP and we do not have any related documentation on customized SMTP, can you please explain a little better on what you mean by this statement?

Additionally, can you share more insight on this internal mail server? Is it built from scratch on your end?

Would you also consider any of the supported SMTPs listed in the documentation for testing purposes?

Hello, @ahmaddanial.

Since this is a custom SMTP and we do not have any related documentation on customized SMTP, can you please explain a little better on what you mean by this statement?

I’m sorry, this expression was not good. And I was misunderstood about SMTP authentication and Connection Security.
Testing mail with settings pattern 4, mattermost said success:
No errors were reported while sending an email. Please check your inbox to make sure.

Connection setting of Mail server is plaintext not encryption, so right setting is pattern 1. But mattermost say “error”. I thought judge of “Enable SMTP Authentication” is reverse, because when mail server say “250-AUTH LOGIN PLAIN” to mattermost, mattermost say “QUIT”. So I tried other patterns.
But, any patterns are mattermost don’t send plaintext password to mail server.

After that I found If you fill in SMTP Username and SMTP Password then you must set Connection Security to TLS or to STARTTLS is written in documentation.

Is there no way to send plaintext password?

Additionally, can you share more insight on this internal mail server? Is it built from scratch on your end?

Mail server built based on this “m-FILTER”.

Would you also consider any of the supported SMTPs listed in the documentation for testing purposes?

Not immediately, I’ll plan to build test mail server with general settings as written in documentation.