@@ -57,6 +57,10 @@ func InitMailRender(subjectTpl *texttmpl.Template, bodyTpl *template.Template) {
57
57
58
58
// SendTestMail sends a test mail
59
59
func SendTestMail (email string ) error {
60
+ if setting .MailService == nil {
61
+ // No mail service configured
62
+ return nil
63
+ }
60
64
return gomail .Send (Sender , NewMessage ([]string {email }, "Gitea Test Email!" , "Gitea Test Email!" ).ToMessage ())
61
65
}
62
66
@@ -90,17 +94,29 @@ func sendUserMail(language string, u *models.User, tpl base.TplName, code, subje
90
94
91
95
// SendActivateAccountMail sends an activation mail to the user (new user registration)
92
96
func SendActivateAccountMail (locale translation.Locale , u * models.User ) {
97
+ if setting .MailService == nil {
98
+ // No mail service configured
99
+ return
100
+ }
93
101
sendUserMail (locale .Language (), u , mailAuthActivate , u .GenerateEmailActivateCode (u .Email ), locale .Tr ("mail.activate_account" ), "activate account" )
94
102
}
95
103
96
104
// SendResetPasswordMail sends a password reset mail to the user
97
105
func SendResetPasswordMail (u * models.User ) {
106
+ if setting .MailService == nil {
107
+ // No mail service configured
108
+ return
109
+ }
98
110
locale := translation .NewLocale (u .Language )
99
111
sendUserMail (u .Language , u , mailAuthResetPassword , u .GenerateEmailActivateCode (u .Email ), locale .Tr ("mail.reset_password" ), "recover account" )
100
112
}
101
113
102
114
// SendActivateEmailMail sends confirmation email to confirm new email address
103
115
func SendActivateEmailMail (u * models.User , email * models.EmailAddress ) {
116
+ if setting .MailService == nil {
117
+ // No mail service configured
118
+ return
119
+ }
104
120
locale := translation .NewLocale (u .Language )
105
121
data := map [string ]interface {}{
106
122
"DisplayName" : u .DisplayName (),
@@ -129,6 +145,10 @@ func SendActivateEmailMail(u *models.User, email *models.EmailAddress) {
129
145
130
146
// SendRegisterNotifyMail triggers a notify e-mail by admin created a account.
131
147
func SendRegisterNotifyMail (u * models.User ) {
148
+ if setting .MailService == nil {
149
+ // No mail service configured
150
+ return
151
+ }
132
152
locale := translation .NewLocale (u .Language )
133
153
134
154
data := map [string ]interface {}{
@@ -156,6 +176,10 @@ func SendRegisterNotifyMail(u *models.User) {
156
176
157
177
// SendCollaboratorMail sends mail notification to new collaborator.
158
178
func SendCollaboratorMail (u , doer * models.User , repo * models.Repository ) {
179
+ if setting .MailService == nil {
180
+ // No mail service configured
181
+ return
182
+ }
159
183
locale := translation .NewLocale (u .Language )
160
184
repoName := repo .FullName ()
161
185
@@ -344,6 +368,10 @@ func sanitizeSubject(subject string) string {
344
368
345
369
// SendIssueAssignedMail composes and sends issue assigned email
346
370
func SendIssueAssignedMail (issue * models.Issue , doer * models.User , content string , comment * models.Comment , recipients []* models.User ) error {
371
+ if setting .MailService == nil {
372
+ // No mail service configured
373
+ return nil
374
+ }
347
375
langMap := make (map [string ][]* models.User )
348
376
for _ , user := range recipients {
349
377
langMap [user .Language ] = append (langMap [user .Language ], user )
0 commit comments