summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2015-07-15 10:27:24 -0800
committerCorey Hulen <corey@hulen.com>2015-07-15 10:27:24 -0800
commitd16a1d6d758c28ae2558232ba6da92798d7dfca3 (patch)
tree0da7ee5d9f4039eeb20f70940483c40943c9aa23 /utils
parent38f9e140e98123eb256968fb31f7fbb2aef978e0 (diff)
parente017babc5ddd66e65469326bf723d5359875c2d1 (diff)
downloadchat-d16a1d6d758c28ae2558232ba6da92798d7dfca3.tar.gz
chat-d16a1d6d758c28ae2558232ba6da92798d7dfca3.tar.bz2
chat-d16a1d6d758c28ae2558232ba6da92798d7dfca3.zip
Merge pull request #171 from mattermost/mm-1415
Fixes mm-1415 adding email bypass flag
Diffstat (limited to 'utils')
-rw-r--r--utils/config.go1
-rw-r--r--utils/mail.go13
2 files changed, 7 insertions, 7 deletions
diff --git a/utils/config.go b/utils/config.go
index eb2ae3050..97cb99f3e 100644
--- a/utils/config.go
+++ b/utils/config.go
@@ -77,6 +77,7 @@ type ImageSettings struct {
}
type EmailSettings struct {
+ ByPassEmail bool
SMTPUsername string
SMTPPassword string
SMTPServer string
diff --git a/utils/mail.go b/utils/mail.go
index 3cd37ffef..0fe7042b7 100644
--- a/utils/mail.go
+++ b/utils/mail.go
@@ -8,14 +8,14 @@ import (
"crypto/tls"
"fmt"
"github.com/mattermost/platform/model"
+ "html"
"net"
"net/mail"
"net/smtp"
- "html"
)
func CheckMailSettings() *model.AppError {
- if len(Cfg.EmailSettings.SMTPServer) == 0 {
+ if len(Cfg.EmailSettings.SMTPServer) == 0 || Cfg.EmailSettings.ByPassEmail {
return model.NewAppError("CheckMailSettings", "No email settings present, mail will not be sent", "")
}
conn, err := connectToSMTPServer()
@@ -79,6 +79,10 @@ func newSMTPClient(conn net.Conn) (*smtp.Client, *model.AppError) {
func SendMail(to, subject, body string) *model.AppError {
+ if len(Cfg.EmailSettings.SMTPServer) == 0 || Cfg.EmailSettings.ByPassEmail {
+ return nil
+ }
+
fromMail := mail.Address{"", Cfg.EmailSettings.FeedbackEmail}
toMail := mail.Address{"", to}
@@ -95,11 +99,6 @@ func SendMail(to, subject, body string) *model.AppError {
}
message += "\r\n<html><body>" + body + "</body></html>"
- if len(Cfg.EmailSettings.SMTPServer) == 0 {
- l4g.Warn("Skipping sending of email because EmailSettings are not configured")
- return nil
- }
-
conn, err1 := connectToSMTPServer()
if err1 != nil {
return err1