mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:17:32 +00:00
feat: add reply-to header in email notification (#6393)
* feat: add reply-to header to smtp messages * fix: grpc reply_to_address min 0 and js var name * fix: add missing translations * fix merge and linting --------- Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
@@ -17,9 +17,10 @@ import (
|
||||
var _ channels.NotificationChannel = (*Email)(nil)
|
||||
|
||||
type Email struct {
|
||||
smtpClient *smtp.Client
|
||||
senderAddress string
|
||||
senderName string
|
||||
smtpClient *smtp.Client
|
||||
senderAddress string
|
||||
senderName string
|
||||
replyToAddress string
|
||||
}
|
||||
|
||||
func InitChannel(ctx context.Context, getSMTPConfig func(ctx context.Context) (*Config, error)) (*Email, error) {
|
||||
@@ -36,9 +37,10 @@ func InitChannel(ctx context.Context, getSMTPConfig func(ctx context.Context) (*
|
||||
logging.New().Debug("successfully initialized smtp email channel")
|
||||
|
||||
return &Email{
|
||||
smtpClient: client,
|
||||
senderName: smtpConfig.FromName,
|
||||
senderAddress: smtpConfig.From,
|
||||
smtpClient: client,
|
||||
senderName: smtpConfig.FromName,
|
||||
senderAddress: smtpConfig.From,
|
||||
replyToAddress: smtpConfig.ReplyToAddress,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -54,6 +56,7 @@ func (email *Email) HandleMessage(message channels.Message) error {
|
||||
}
|
||||
emailMsg.SenderEmail = email.senderAddress
|
||||
emailMsg.SenderName = email.senderName
|
||||
emailMsg.ReplyToAddress = email.replyToAddress
|
||||
// To && From
|
||||
if err := email.smtpClient.Mail(emailMsg.SenderEmail); err != nil {
|
||||
return caos_errs.ThrowInternalf(err, "EMAIL-s3is3", "could not set sender: %v", emailMsg.SenderEmail)
|
||||
|
@@ -1,10 +1,11 @@
|
||||
package smtp
|
||||
|
||||
type Config struct {
|
||||
SMTP SMTP
|
||||
Tls bool
|
||||
From string
|
||||
FromName string
|
||||
SMTP SMTP
|
||||
Tls bool
|
||||
From string
|
||||
FromName string
|
||||
ReplyToAddress string
|
||||
}
|
||||
|
||||
type SMTP struct {
|
||||
|
@@ -19,9 +19,10 @@ func (n *NotificationQueries) GetSMTPConfig(ctx context.Context) (*smtp.Config,
|
||||
return nil, err
|
||||
}
|
||||
return &smtp.Config{
|
||||
From: config.SenderAddress,
|
||||
FromName: config.SenderName,
|
||||
Tls: config.TLS,
|
||||
From: config.SenderAddress,
|
||||
FromName: config.SenderName,
|
||||
ReplyToAddress: config.ReplyToAddress,
|
||||
Tls: config.TLS,
|
||||
SMTP: smtp.SMTP{
|
||||
Host: config.Host,
|
||||
User: config.User,
|
||||
|
@@ -23,6 +23,7 @@ type Email struct {
|
||||
CC []string
|
||||
SenderEmail string
|
||||
SenderName string
|
||||
ReplyToAddress string
|
||||
Subject string
|
||||
Content string
|
||||
TriggeringEvent eventstore.Event
|
||||
@@ -35,6 +36,9 @@ func (msg *Email) GetContent() (string, error) {
|
||||
from = fmt.Sprintf("%s <%s>", msg.SenderName, msg.SenderEmail)
|
||||
}
|
||||
headers["From"] = from
|
||||
if msg.ReplyToAddress != "" {
|
||||
headers["Reply-to"] = msg.ReplyToAddress
|
||||
}
|
||||
headers["Return-Path"] = msg.SenderEmail
|
||||
headers["To"] = strings.Join(msg.Recipients, ", ")
|
||||
headers["Cc"] = strings.Join(msg.CC, ", ")
|
||||
|
Reference in New Issue
Block a user