mirror of https://github.com/go-gitea/gitea.git
Use Golang net/smtp instead of gomail's smtp to send email (#36055)
Replace #36032 Fix #36030 This PR use `net/smtp` instead of gomail's smtp. Now github.com/wneessen/go-mail will be used only for generating email message body. --------- Co-authored-by: Giteabot <teabot@gitea.io>pull/36079/head^2
parent
e30a130b9a
commit
ee6e371e44
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
package sender
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestSanitizeEmailAddress(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
input string
|
||||||
|
expected string
|
||||||
|
hasError bool
|
||||||
|
}{
|
||||||
|
{"abc@gitea.com", "abc@gitea.com", false},
|
||||||
|
{"<abc@gitea.com>", "abc@gitea.com", false},
|
||||||
|
{"ssss.com", "", true},
|
||||||
|
{"<invalid-email>", "", true},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
result, err := sanitizeEmailAddress(tt.input)
|
||||||
|
if (err != nil) != tt.hasError {
|
||||||
|
t.Errorf("sanitizeEmailAddress(%q) unexpected error status: got %v, want error: %v", tt.input, err != nil, tt.hasError)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("sanitizeEmailAddress(%q) = %q; want %q", tt.input, result, tt.expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue