Enabling email notifications caues mattermost not to start

I get the below error when I set SendEmailNotifications to true, if I set it to false everything works fine. I can even re-enable it in the web interface and send test emails, but if I restart mattermost it fails unless I manually reset it to false.

Mail Config
“EmailSettings”: {
“EnableSignUpWithEmail”: true,
“EnableSignInWithEmail”: true,
“EnableSignInWithUsername”: true,
“SendEmailNotifications”: true,
“RequireEmailVerification”: false,
“FeedbackName”: “Coconuts”,
“FeedbackEmail”: “donotreply@no.com”,
“SMTPUsername”: “email@email.com”,
“SMTPPassword”: “password”,
“SMTPServer”: “smtp.gmail.com”,
“SMTPPort”: “587”,
“ConnectionSecurity”: “TLS”,
“InviteSalt”: “bjlSR4QqkXFBr7TP4oDzlfZmcNuH9YoS”,
“PasswordResetSalt”: “vZ4DcKyVVRlKHHJpexcuXzojkE5PZ5eL”,
“SendPushNotifications”: false,
“PushNotificationServer”: “”,
“PushNotificationContents”: “generic”
},

error:

root@mattermost:/home/mattermost/mattermost/bin# ./platform -config=/home/mattermost/mattermost/config/config.json
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: interface conversion: interface is runtime.errorString, not string
[signal 0xb code=0x1 addr=0x0 pc=0x780b9d]

goroutine 1 [running]:
panic(0xcd1aa0, 0xc82012cc40)
/usr/local/go/src/runtime/panic.go:481 +0x3e6
main.doLoadConfig.func1(0xc820251d38)
/var/lib/jenkins/jobs/mattermost-platform-release/workspace/src/github.com/mattermost/platform/mattermost.go:73 +0x6f
panic(0xccbec0, 0xc82000e0c0)
/usr/local/go/src/runtime/panic.go:443 +0x4e9
github.com/mattermost/platform/utils.TestConnection(0xc82007cb00)
/var/lib/jenkins/jobs/mattermost-platform-release/workspace/src/github.com/mattermost/platform/utils/mail.go:89 +0x32d
github.com/mattermost/platform/utils.LoadConfig(0x7ffd77bd38da, 0x2e)
/var/lib/jenkins/jobs/mattermost-platform-release/workspace/src/github.com/mattermost/platform/utils/config.go:181 +0x10aa
main.doLoadConfig(0x7ffd77bd38da, 0x2e, 0x0, 0x0)
/var/lib/jenkins/jobs/mattermost-platform-release/workspace/src/github.com/mattermost/platform/mattermost.go:76 +0x6a
main.main()
/var/lib/jenkins/jobs/mattermost-platform-release/workspace/src/github.com/mattermost/platform/mattermost.go:84 +0x43

Try validating your config.json in http://jsonlint.com/. There’s a bug in 3.1 outputting cryptic error messages. Most of the time it’s a typo in config.json.

I get Valid JSON.
After the initial setup, I did not edit the config directly until I ran into this issue.

Could you try setting it to the version that works, starting the server, then updating via System Console > Notifications > Email and saving the file?

This would rule out typos in the config.json

I have multiple times with no success

I did notice that it incorrectly set the setting once. I had initially put 465 as the port, but when I check the file it was set to 4 and the username and password were blank

Thanks for the report @vorgusa There was a bug where an invalid json field in the config file or a failed connection with EmailSettings may cause this error. It’s fixed on master and will be in for the next release.

In the meantime, you may try the following steps as a workaround:

  1. Stop the server
  2. Remove EmailSettings from your config.json
  3. Start the server
  4. From the System Console re-add the Email Settings

I am facing the same issue. Still; I encountered the same problem a year ago but wasn’t able to trace this back to the email settings. ([solved] Restoring config.json fails)

If I set SendEmailNotifications=true the server fails to start. (It hangs after pinging the db.) If I set SendEmailNotifications=false the server starts just fine. This is very frustrating. My mattermost.conf is created by gitlab.

My config.json validates with all linters that have been used above, so please don’t answer with another “your json is invalid”. This is clearly a bug in Mattermost.

Hi @arnuschky, thank you for letting us know.

What Mattermost server version are you on? Do you see errors in Mattermost logs?

I am using the version packaged with Gitlab omnibus:

Version: 5.9.0
Build Number: 5.9.1
Build Date: Wed Apr 24 08:47:10 UTC 2019
Build Hash: c201065b4f25d4794ae86c077efb60c6f934fbc8
Build Enterprise Ready: false
DB Version: 5.9.0