Fixes mm-1415 adding email bypass flag

This commit is contained in:
=Corey Hulen
2015-07-12 23:36:52 -08:00
parent 27cab0f507
commit 252d0f3924
7 changed files with 29 additions and 28 deletions

View File

@@ -77,6 +77,7 @@ type ImageSettings struct {
}
type EmailSettings struct {
ByPassEmail bool
SMTPUsername string
SMTPPassword string
SMTPServer string

View File

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