aboutsummaryrefslogtreecommitdiffstats
path: root/services/mailer/mail.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2023-01-22 15:23:52 +0100
committerGitHub <noreply@github.com>2023-01-22 08:23:52 -0600
commit21dd4a252a98fee4e8b4304d63685c4fae7cc077 (patch)
tree20e81cfe513753adc19c5a1902289d6925cb3aa2 /services/mailer/mail.go
parent6737e1c5d589e9521e4e07824a2fc9280270e19f (diff)
downloadgitea-21dd4a252a98fee4e8b4304d63685c4fae7cc077.tar.gz
gitea-21dd4a252a98fee4e8b4304d63685c4fae7cc077.zip
Prevent multiple `To` recipients (#22566)
Change the mailer interface to prevent leaking of possible hidden email addresses when sending to multiple recipients. Co-authored-by: Gusted <williamzijl7@hotmail.com>
Diffstat (limited to 'services/mailer/mail.go')
-rw-r--r--services/mailer/mail.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/services/mailer/mail.go b/services/mailer/mail.go
index 7c7ad54714..351b79b5df 100644
--- a/services/mailer/mail.go
+++ b/services/mailer/mail.go
@@ -61,7 +61,7 @@ func SendTestMail(email string) error {
// No mail service configured
return nil
}
- return gomail.Send(Sender, NewMessage([]string{email}, "Gitea Test Email!", "Gitea Test Email!").ToMessage())
+ return gomail.Send(Sender, NewMessage(email, "Gitea Test Email!", "Gitea Test Email!").ToMessage())
}
// sendUserMail sends a mail to the user
@@ -86,7 +86,7 @@ func sendUserMail(language string, u *user_model.User, tpl base.TplName, code, s
return
}
- msg := NewMessage([]string{u.Email}, subject, content.String())
+ msg := NewMessage(u.Email, subject, content.String())
msg.Info = fmt.Sprintf("UID: %d, %s", u.ID, info)
SendAsync(msg)
@@ -137,7 +137,7 @@ func SendActivateEmailMail(u *user_model.User, email *user_model.EmailAddress) {
return
}
- msg := NewMessage([]string{email.Email}, locale.Tr("mail.activate_email"), content.String())
+ msg := NewMessage(email.Email, locale.Tr("mail.activate_email"), content.String())
msg.Info = fmt.Sprintf("UID: %d, activate email", u.ID)
SendAsync(msg)
@@ -168,7 +168,7 @@ func SendRegisterNotifyMail(u *user_model.User) {
return
}
- msg := NewMessage([]string{u.Email}, locale.Tr("mail.register_notify"), content.String())
+ msg := NewMessage(u.Email, locale.Tr("mail.register_notify"), content.String())
msg.Info = fmt.Sprintf("UID: %d, registration notify", u.ID)
SendAsync(msg)
@@ -202,7 +202,7 @@ func SendCollaboratorMail(u, doer *user_model.User, repo *repo_model.Repository)
return
}
- msg := NewMessage([]string{u.Email}, subject, content.String())
+ msg := NewMessage(u.Email, subject, content.String())
msg.Info = fmt.Sprintf("UID: %d, add collaborator", u.ID)
SendAsync(msg)
@@ -322,7 +322,7 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
msgs := make([]*Message, 0, len(recipients))
for _, recipient := range recipients {
- msg := NewMessageFrom([]string{recipient.Email}, ctx.Doer.DisplayName(), setting.MailService.FromEmail, subject, mailBody.String())
+ msg := NewMessageFrom(recipient.Email, ctx.Doer.DisplayName(), setting.MailService.FromEmail, subject, mailBody.String())
msg.Info = fmt.Sprintf("Subject: %s, %s", subject, info)
msg.SetHeader("Message-ID", msgID)