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:
Miguel Cabrerizo
2023-08-29 09:08:24 +02:00
committed by GitHub
parent 9b43e28c23
commit fd00ac533a
31 changed files with 307 additions and 120 deletions

View File

@@ -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)