mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Fixes mm-1415 adding email bypass flag
This commit is contained in:
@@ -77,6 +77,7 @@ type ImageSettings struct {
|
||||
}
|
||||
|
||||
type EmailSettings struct {
|
||||
ByPassEmail bool
|
||||
SMTPUsername string
|
||||
SMTPPassword string
|
||||
SMTPServer string
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user