π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Remove isEnabled from config
Vishald5f0334a3444
diff --git a/server/configurations/local.yaml b/server/configurations/local.yamlindex 2b90deaaf8..97dd353e1f 100644--- a/server/configurations/local.yaml+++ b/server/configurations/local.yaml@@ -157,22 +157,29 @@ key:jwt:secret: i2DecQmfGreG6q1vBj5tCokhlN41gcfS2cjOs9Po-u8=+# SMTP configuration (optional)+#+# Configure credentials here for sending mails from museum (e.g. OTP emails).+#+# The smtp credentials will be used if the host is specified. Otherwise it will+# try to use the transmail credentials. Ideally, one of smtp or transmail should+# be configured for a production instance.+smtp:+ host:+ port:+ username:+ password:+# Zoho Zeptomail config (optional)-# Use case: Sending emails+#+# This is an alternative to the `smtp` configuration for sending emails. If this+# is set (and SMTP credentials are not set), then museum will use the transmail+# SDK for sending emails using Zoho Zeptomail.transmail:# Transmail token# Mail agent: devkey:-# AWS SES-# Use case: Sending mails-smtp:- isEnabled: false- host:- port:- username:- password:-# Apple config (optional)# Use case: In-app purchasesapple:@@ -288,4 +295,4 @@ jobs:# By default, this job is disabled.enabled: false# If provided, only objects that begin with this prefix are pruned.- prefix: ""+ prefix: ""\ No newline at end of filediff --git a/server/pkg/utils/email/email.go b/server/pkg/utils/email/email.goindex 3d29c76324..46202313e7 100644--- a/server/pkg/utils/email/email.go+++ b/server/pkg/utils/email/email.go@@ -21,6 +21,78 @@ import (// Send sends an emailfunc Send(toEmails []string, fromName string, fromEmail string, subject string, htmlBody string, inlineImages []map[string]interface{}) error {+ smtpHost := viper.GetString("smtp.host")+ if smtpHost != "" {+ 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 {+ if len(toEmails) == 0 {+ return ente.ErrBadRequest+ }++ smtpServer := viper.GetString("smtp.host")+ smtpPort := viper.GetString("smtp.port")+ smtpUsername := viper.GetString("smtp.username")+ smtpPassword := viper.GetString("smtp.password")++ var emailMessage string++ // Construct 'emailAddresses' with comma-separated email addresses+ var emailAddresses string+ for i, email := range toEmails {+ if i != 0 {+ emailAddresses += ","+ }+ emailAddresses += email+ }++ header := "From: " + fromName + " <" + fromEmail + ">\n" ++ "To: " + emailAddresses + "\n" ++ "Subject: " + subject + "\n" ++ "MIME-Version: 1.0\n" ++ "Content-Type: multipart/related; boundary=boundary\n\n" ++ "--boundary\n"+ htmlContent := "Content-Type: text/html; charset=us-ascii\n\n" + htmlBody + "\n"++ emailMessage = header + htmlContent++ if inlineImages == nil {+ emailMessage += "--boundary--"+ } else {+ for _, inlineImage := range inlineImages {++ emailMessage += "--boundary\n"+ var mimeType = inlineImage["mime_type"].(string)+ var contentID = inlineImage["cid"].(string)+ var imgBase64Str = inlineImage["content"].(string)++ var image = "Content-Type: " + mimeType + "\n" ++ "Content-Transfer-Encoding: base64\n" ++ "Content-ID: <" + contentID + ">\n" ++ "Content-Disposition: inline\n\n" + imgBase64Str + "\n"++ emailMessage += image+ }+ emailMessage += "--boundary--"+ }++ // Send the email to each recipient+ for _, toEmail := range toEmails {+ auth := smtp.PlainAuth("", smtpUsername, smtpPassword, smtpServer)+ err := smtp.SendMail(smtpServer+":"+smtpPort, auth, fromEmail, []string{toEmail}, []byte(emailMessage))+ if err != nil {+ return stacktrace.Propagate(err, "")+ }+ }++ return nil+}++func sendViaTransmail(toEmails []string, fromName string, fromEmail string, subject string, htmlBody string, inlineImages []map[string]interface{}) error {if len(toEmails) == 0 {return ente.ErrBadRequest}@@ -71,12 +143,7 @@ func SendTemplatedEmail(to []string, fromName string, fromEmail string, subjectreturn 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 {@@ -104,66 +171,3 @@ func getMailBody(templateName string, templateData map[string]interface{}) (stri}return htmlbody.String(), nil}--func sendViaSMTP(toEmails []string, fromName string, fromEmail string, subject string, htmlBody string, inlineImages []map[string]interface{}) error {- if len(toEmails) == 0 {- return ente.ErrBadRequest- }-- smtpServer := viper.GetString("smtp.host")- smtpPort := viper.GetString("smtp.port")- smtpUsername := viper.GetString("smtp.username")- smtpPassword := viper.GetString("smtp.password")-- var emailMessage string-- // Construct 'emailAddresses' with comma-separated email addresses- var emailAddresses string- for i, email := range toEmails {- if i != 0 {- emailAddresses += ","- }- emailAddresses += email- }-- header := "From: " + fromName + " <" + fromEmail + ">\n" +- "To: " + emailAddresses + "\n" +- "Subject: " + subject + "\n" +- "MIME-Version: 1.0\n" +- "Content-Type: multipart/related; boundary=boundary\n\n" +- "--boundary\n"- htmlContent := "Content-Type: text/html; charset=us-ascii\n\n" + htmlBody + "\n"-- emailMessage = header + htmlContent-- if inlineImages == nil {- emailMessage += "--boundary--"- } else {- for _, inlineImage := range inlineImages {-- emailMessage += "--boundary\n"- var mimeType = inlineImage["mime_type"].(string)- var contentID = inlineImage["cid"].(string)- var imgBase64Str = inlineImage["content"].(string)-- var image = "Content-Type: " + mimeType + "\n" +- "Content-Transfer-Encoding: base64\n" +- "Content-ID: <" + contentID + ">\n" +- "Content-Disposition: inline\n\n" + imgBase64Str + "\n"-- emailMessage += image- }- emailMessage += "--boundary--"- }-- // Send the email to each recipient- for _, toEmail := range toEmails {- auth := smtp.PlainAuth("", smtpUsername, smtpPassword, smtpServer)- err := smtp.SendMail(smtpServer+":"+smtpPort, auth, fromEmail, []string{toEmail}, []byte(emailMessage))- if err != nil {- return stacktrace.Propagate(err, "")- }- }-- return nil-}