You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2026/10/22 19:17:49 UTC
(airavata-custos) branch email-no-login created (now 91bcdd187)
This is an automated email from the ASF dual-hosted git repository.
lahirujayathilake pushed a change to branch email-no-login
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git
at 91bcdd187 Send email through a relay without a login
This branch includes the following new commits:
new 91bcdd187 Send email through a relay without a login
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(airavata-custos) 01/01: Send email through a relay without a login
Posted by la...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
lahirujayathilake pushed a commit to branch email-no-login
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git
commit 91bcdd187691483f22fc632030f6621c5c76c3c7
Author: lahiruj <la...@gmail.com>
AuthorDate: Thu Oct 22 15:17:22 2026 -0400
Send email through a relay without a login
---
.../Email/internal/notify/live_send_test.go | 7 ++++++-
.../Notification/Email/internal/notify/smtp.go | 20 ++++++++++++--------
connectors/Notification/Email/pkg/email/loader.go | 2 +-
3 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/connectors/Notification/Email/internal/notify/live_send_test.go b/connectors/Notification/Email/internal/notify/live_send_test.go
index 544e46d32..d49ebf52e 100644
--- a/connectors/Notification/Email/internal/notify/live_send_test.go
+++ b/connectors/Notification/Email/internal/notify/live_send_test.go
@@ -22,6 +22,7 @@ package notify
import (
"context"
"os"
+ "strconv"
"testing"
)
@@ -31,7 +32,11 @@ func TestLiveSend(t *testing.T) {
if to == "" {
t.Skip("EMAIL_TEST_TO not set")
}
- sender, err := NewSMTP(os.Getenv("EMAIL_SMTP_HOST"), 587, os.Getenv("EMAIL_SMTP_USERNAME"), os.Getenv("EMAIL_SMTP_PASSWORD"), os.Getenv("EMAIL_FROM"))
+ port := 587
+ if p, err := strconv.Atoi(os.Getenv("EMAIL_SMTP_PORT")); err == nil {
+ port = p
+ }
+ sender, err := NewSMTP(os.Getenv("EMAIL_SMTP_HOST"), port, os.Getenv("EMAIL_SMTP_USERNAME"), os.Getenv("EMAIL_SMTP_PASSWORD"), os.Getenv("EMAIL_FROM"))
if err != nil {
t.Fatal(err)
}
diff --git a/connectors/Notification/Email/internal/notify/smtp.go b/connectors/Notification/Email/internal/notify/smtp.go
index cd4501d5c..115de8094 100644
--- a/connectors/Notification/Email/internal/notify/smtp.go
+++ b/connectors/Notification/Email/internal/notify/smtp.go
@@ -34,20 +34,24 @@ type Sender interface {
Send(ctx context.Context, m Message) error
}
-// SMTP sends through any relay that accepts authenticated STARTTLS on the configured port.
type SMTP struct {
client *mail.Client
from string
}
+// NewSMTP TLS is required only with a login, so a password never goes out unencrypted.
func NewSMTP(host string, port int, username, password, from string) (*SMTP, error) {
- client, err := mail.NewClient(host,
- mail.WithPort(port),
- mail.WithSMTPAuth(mail.SMTPAuthPlain),
- mail.WithUsername(username),
- mail.WithPassword(password),
- mail.WithTLSPolicy(mail.TLSMandatory),
- )
+ opts := []mail.Option{mail.WithPort(port), mail.WithTLSPolicy(mail.TLSOpportunistic)}
+ if username != "" {
+ opts = []mail.Option{
+ mail.WithPort(port),
+ mail.WithTLSPolicy(mail.TLSMandatory),
+ mail.WithSMTPAuth(mail.SMTPAuthPlain),
+ mail.WithUsername(username),
+ mail.WithPassword(password),
+ }
+ }
+ client, err := mail.NewClient(host, opts...)
if err != nil {
return nil, err
}
diff --git a/connectors/Notification/Email/pkg/email/loader.go b/connectors/Notification/Email/pkg/email/loader.go
index a97db7468..0869898a6 100644
--- a/connectors/Notification/Email/pkg/email/loader.go
+++ b/connectors/Notification/Email/pkg/email/loader.go
@@ -62,7 +62,7 @@ func LoadConnector(_ context.Context, _ *sqlx.DB, eventBus *events.Bus, coreServ
LogoURL: get("logo_url"),
}
for key, v := range map[string]string{
- "smtp_host": host, "username": username, "password": password, "from": from,
+ "smtp_host": host, "from": from,
"site_name": site.SiteName, "portal_url": site.PortalURL, "cluster_host": site.ClusterHost, "support_email": site.SupportEmail,
} {
if v == "" {