Mirror the decision tree
This commit is contained in:
parent
a64cbf79dc
commit
2114644ed1
|
@ -19,6 +19,16 @@ import (
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Send sends an email
|
||||||
|
func Send(toEmails []string, fromName string, fromEmail string, subject string, htmlBody string, inlineImages []map[string]interface{}) error {
|
||||||
|
isSESEnabled := viper.GetBool("smtp.isEnabled")
|
||||||
|
if isSESEnabled {
|
||||||
|
return sendViaSMTP(toEmails, fromName, fromEmail, subject, htmlBody, inlineImages)
|
||||||
|
} else {
|
||||||
|
return sendViaTransmail(toEmails, fromName, fromEmail, subject, htmlBody, inlineImages)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func sendViaSMTP(toEmails []string, fromName string, fromEmail string, subject string, htmlBody string, inlineImages []map[string]interface{}) error {
|
func sendViaSMTP(toEmails []string, fromName string, fromEmail string, subject string, htmlBody string, inlineImages []map[string]interface{}) error {
|
||||||
if len(toEmails) == 0 {
|
if len(toEmails) == 0 {
|
||||||
return ente.ErrBadRequest
|
return ente.ErrBadRequest
|
||||||
|
@ -82,8 +92,7 @@ func sendViaSMTP(toEmails []string, fromName string, fromEmail string, subject s
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send sends an email
|
func sendViaTransmail(toEmails []string, fromName string, fromEmail string, subject string, htmlBody string, inlineImages []map[string]interface{}) error {
|
||||||
func Send(toEmails []string, fromName string, fromEmail string, subject string, htmlBody string, inlineImages []map[string]interface{}) error {
|
|
||||||
if len(toEmails) == 0 {
|
if len(toEmails) == 0 {
|
||||||
return ente.ErrBadRequest
|
return ente.ErrBadRequest
|
||||||
}
|
}
|
||||||
|
@ -134,13 +143,8 @@ func SendTemplatedEmail(to []string, fromName string, fromEmail string, subject
|
||||||
return stacktrace.Propagate(err, "")
|
return stacktrace.Propagate(err, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
isSESEnabled := viper.GetBool("smtp.isEnabled")
|
|
||||||
if isSESEnabled {
|
|
||||||
return sendViaSMTP(to, fromName, fromEmail, subject, body, inlineImages)
|
|
||||||
} else {
|
|
||||||
return Send(to, fromName, fromEmail, subject, body, inlineImages)
|
return Send(to, fromName, fromEmail, subject, body, inlineImages)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func GetMaskedEmail(email string) string {
|
func GetMaskedEmail(email string) string {
|
||||||
at := strings.LastIndex(email, "@")
|
at := strings.LastIndex(email, "@")
|
||||||
|
|
Loading…
Reference in a new issue