Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Remove transmail mailer path

Manav Rathi383165df5f69
diff --git a/docs/docs/self-hosting/installation/config.md b/docs/docs/self-hosting/installation/config.md
index 3effd2cb91..31ed2e9b3f 100644
--- a/docs/docs/self-hosting/installation/config.md
+++ b/docs/docs/self-hosting/installation/config.md
@@ -132,7 +132,7 @@ go run tools/gen-random-keys/main.go
### Email
-You may wish to send emails for verification codes instead of [hardcoding them](/self-hosting/administration/users#use-hardcoded-otts). In such cases, you can configure SMTP (or Zoho Transmail, for bulk emails).
+You may wish to send emails for verification codes instead of [hardcoding them](/self-hosting/administration/users#use-hardcoded-otts). In such cases, you can configure SMTP.
Set the host and port accordingly with your credentials in `museum.yaml`
@@ -162,7 +162,11 @@ smtp:
| `smtp.email` | Sender email address | |
| `smtp.sender-name` | Custom name for email sender | |
| `smtp.encryption` | Encryption method (tls, ssl) | |
-| `transmail.key` | Zeptomail API key | |
+
+
+> [!NOTE]
+>
+> The legacy `transmail.key` is no longer supported, and should be converted to use [SMTP credentials](https://help.zoho.com/portal/en/kb/zeptomail/faqs/sending-emails/articles/how-to-configure-smtp) instead.
### WebAuthn Passkey Support
diff --git a/server/configurations/local.yaml b/server/configurations/local.yaml
index 319c585042..d4e5ae4e8b 100644
--- a/server/configurations/local.yaml
+++ b/server/configurations/local.yaml
@@ -272,10 +272,6 @@ jwt:
#
# 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.
-#
# username and password are optional (e.g. if you're using a local relay server
# and don't need authentication).
smtp:
@@ -292,16 +288,6 @@ smtp:
# Optional encryption method. If tls or ssl is chosen, encryption is enabled.
encryption:
-# Zoho Zeptomail config (optional)
-#
-# 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: dev
- key:
-
# Apple config (optional)
# Use case: In-app purchases
apple:
diff --git a/server/ente/email.go b/server/ente/email.go
index b2671cca30..bd838997d2 100644
--- a/server/ente/email.go
+++ b/server/ente/email.go
@@ -1,13 +1,5 @@
package ente
-const (
- // TransmailEndPoint is the mailing endpoint of TransMail (now called
- // ZeptoMail), Zoho's transactional email service.
- TransmailEndPoint = "https://api.transmail.com/v1.1/email"
- // BounceAddress is the emailAddress to send bounce messages to
- TransmailEndBounceAddress = "[email protected]"
-)
-
type SendEmailRequest struct {
To []string `json:"to" binding:"required"`
FromName string `json:"fromName" binding:"required"`
@@ -15,22 +7,3 @@ type SendEmailRequest struct {
Subject string `json:"subject" binding:"required"`
Body string `json:"body" binding:"required"`
}
-
-type Mail struct {
- BounceAddress string `json:"bounce_address"`
- From EmailAddress `json:"from"`
- To []ToEmailAddress `json:"to"`
- Bcc []ToEmailAddress `json:"bcc"`
- Subject string `json:"subject"`
- Htmlbody string `json:"htmlbody"`
- InlineImages []map[string]interface{} `json:"inline_images"`
-}
-
-type ToEmailAddress struct {
- EmailAddress EmailAddress `json:"email_address"`
-}
-
-type EmailAddress struct {
- Address string `json:"address"`
- Name string `json:"name"`
-}
diff --git a/server/pkg/utils/email/email.go b/server/pkg/utils/email/email.go
index 26e12d7a02..19b2e3bfae 100644
--- a/server/pkg/utils/email/email.go
+++ b/server/pkg/utils/email/email.go
@@ -2,18 +2,15 @@
//
// These functions can be used for directly sending emails to given email
// addresses. This is used for transactional emails, for example OTP requests.
-// Currently, we use Zoho Transmail to send out the actual mail.
package email
import (
"bytes"
"crypto/tls"
- "encoding/json"
"fmt"
"html/template"
"mime/quotedprintable"
"net"
- "net/http"
"net/smtp"
"path"
"slices"
@@ -107,19 +104,17 @@ func buildHTMLMIMEPart(htmlBody string) (string, error) {
// Send sends an email
func 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
}
+ if viper.GetString("smtp.host") == "" {
+ log.Infof("Skipping sending email to %s: %s", toEmails[0], subject)
+ return nil
+ }
+ return sendViaSMTP(toEmails, fromName, fromEmail, subject, htmlBody, inlineImages)
+}
+func sendViaSMTP(toEmails []string, fromName string, fromEmail string, subject string, htmlBody string, inlineImages []map[string]interface{}) error {
smtpServer := viper.GetString("smtp.host")
smtpPort := viper.GetString("smtp.port")
smtpUsername := viper.GetString("smtp.username")
@@ -288,62 +283,6 @@ func sendWithClient(client *smtp.Client, auth smtp.Auth, from string, to []strin
return stacktrace.Propagate(err, "")
}
-func sendViaTransmail(toEmails []string, fromName string, fromEmail string, subject string, htmlBody string, inlineImages []map[string]interface{}) error {
- if len(toEmails) == 0 {
- return ente.ErrBadRequest
- }
-
- authKey := viper.GetString("transmail.key")
- silent := viper.GetBool("internal.silent")
- if authKey == "" || silent {
- log.Infof("Skipping sending email to %s: %s", toEmails[0], subject)
- return nil
- }
-
- // Sanitize subject and from name to avoid accidental multi-line fields
- cleanSubject := sanitizeHeaderValue(subject)
- cleanFromName := sanitizeHeaderValue(fromName)
-
- var to []ente.ToEmailAddress
- for _, toEmail := range toEmails {
- // Reject clearly invalid recipients attempting header injection
- if containsCRLF(toEmail) {
- return stacktrace.Propagate(ente.ErrBadRequest, "invalid recipient email")
- }
- to = append(to, ente.ToEmailAddress{EmailAddress: ente.EmailAddress{Address: toEmail}})
- }
- if containsCRLF(fromEmail) {
- return stacktrace.Propagate(ente.ErrBadRequest, "invalid from email")
- }
- mail := &ente.Mail{
- BounceAddress: ente.TransmailEndBounceAddress,
- From: ente.EmailAddress{Address: fromEmail, Name: cleanFromName},
- Subject: cleanSubject,
- Htmlbody: htmlBody,
- InlineImages: inlineImages,
- }
- if len(toEmails) == 1 {
- mail.To = to
- } else {
- mail.Bcc = to
- }
- postBody, err := json.Marshal(mail)
- if err != nil {
- return stacktrace.Propagate(err, "")
- }
- reqBody := bytes.NewBuffer(postBody)
- client := &http.Client{}
- req, err := http.NewRequest("POST", ente.TransmailEndPoint, reqBody)
- if err != nil {
- return stacktrace.Propagate(err, "")
- }
- req.Header.Set("accept", "application/json")
- req.Header.Set("content-type", "application/json")
- req.Header.Set("authorization", authKey)
- _, err = client.Do(req)
- return stacktrace.Propagate(err, "")
-}
-
func SendTemplatedEmail(to []string, fromName string, fromEmail string, subject string, templateName string, templateData map[string]interface{}, inlineImages []map[string]interface{}) error {
body, err := getMailBody(templateName, templateData)
if err != nil {