# Can't send email

**URL:** <https://forum.mattermost.com/t/cant-send-email/9702>\
**Category:** Troubleshooting\
**Created:** [May 7, 2020, 8:39am UTC](https://forum.mattermost.com/t/cant-send-email/9702 "2020-05-07T08:39:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![maki](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@maki](https://forum.mattermost.com/u/maki)\
**Post date:** [May 7, 2020, 8:39am UTC](https://forum.mattermost.com/t/cant-send-email/9702/1 "2020-05-07T08:39:30Z")

</div>

#### Summary

can’t send email

#### Steps to reproduce

- mattermost version 5.19.0
- CentOS 7

I constructed according to

- [https://docs.mattermost.com/install/install-rhel-7.html](https://docs.mattermost.com/install/install-rhel-7.html)
- [https://docs.mattermost.com/install/smtp-email-setup.html](https://docs.mattermost.com/install/smtp-email-setup.html)

#### Expected behavior

Mail server can’t receive SMTP certification information.

#### Observed behavior

mattermost.log is

```auto
{
	"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.

```auto
    "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.

---

<div class="post-metadata">

**Author:** ![ahmaddanial](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/ahmaddanial/32/2938_2.png) [@ahmaddanial](https://forum.mattermost.com/u/ahmaddanial)\
**Post date:** [May 7, 2020, 10:14pm UTC](https://forum.mattermost.com/t/cant-send-email/9702/2 "2020-05-07T22:14:08Z")

</div>

Hello, @maki

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

> [@maki](#):
>
> Connection unsuccessful: SendMail: Failed to authenticate on SMTP server, unencrypted connection

Can you please confirm which SMTP setting you are using based on the [sample](https://docs.mattermost.com/install/smtp-email-setup.html#sample-smtp-settings) 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:

- [TLS Connection Error SendMail tls: first record does not look like a TLS handshake](https://forum.mattermost.com/t/tls-connection-error-sendmail-tls-first-record-does-not-look-like-a-tls-handshake/7283)

---

<div class="post-metadata">

**Author:** ![maki](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@maki](https://forum.mattermost.com/u/maki)\
**Post date:** [May 11, 2020, 10:21am UTC](https://forum.mattermost.com/t/cant-send-email/9702/3 "2020-05-11T10:21:04Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![ahmaddanial](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/ahmaddanial/32/2938_2.png) [@ahmaddanial](https://forum.mattermost.com/u/ahmaddanial)\
**Post date:** [May 12, 2020, 2:51am UTC](https://forum.mattermost.com/t/cant-send-email/9702/4 "2020-05-12T02:51:57Z")

</div>

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** :

> [@maki](#):
>
> Authentication of Mail server is plaintext, so I think SMTP connection security is “None”.

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?

> [@maki](#):
>
> Enable SMTP Authentication: false  
> Connection Security: None  
> →Success. But Mail Server is not receive SMTP certification information. ID and password are nothing.

> [@maki](#):
>
> Enable SMTP Authentication: false  
> Connection Security: STARTTLS  
> →Success. But Mail Server is not receive SMTP certification information. ID and password are nothing

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?

---

<div class="post-metadata">

**Author:** ![maki](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@maki](https://forum.mattermost.com/u/maki)\
**Post date:** [May 12, 2020, 8:59am UTC](https://forum.mattermost.com/t/cant-send-email/9702/5 "2020-05-12T08:59:26Z")

</div>

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](https://www.daj.jp/en/) “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.
