fix(smtp): update address formatting in SMTP connection functions
- Replaced fmt.Sprintf with net.JoinHostPort for constructing the SMTP address in smtpValidateConnection and smtpSendTestEmail functions, improving address handling and ensuring proper formatting.
This commit is contained in:
parent
bde4442ff6
commit
a58cac6d5c
1 changed files with 2 additions and 2 deletions
|
|
@ -380,7 +380,7 @@ func handleSmtpTest(c *gin.Context) {
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
func smtpValidateConnection(host string, port int, encryption, username, password string) error {
|
||||
addr := fmt.Sprintf("%s:%d", host, port)
|
||||
addr := net.JoinHostPort(host, fmt.Sprintf("%d", port))
|
||||
auth := smtp.PlainAuth("", username, password, host)
|
||||
|
||||
switch encryption {
|
||||
|
|
@ -443,7 +443,7 @@ func smtpValidateConnection(host string, port int, encryption, username, passwor
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
func smtpSendTestEmail(host string, port int, encryption, username, password, fromName, fromEmail, toEmail string) error {
|
||||
addr := fmt.Sprintf("%s:%d", host, port)
|
||||
addr := net.JoinHostPort(host, fmt.Sprintf("%d", port))
|
||||
|
||||
subject := "Yao SMTP Test"
|
||||
body := "This is a test email from Yao to verify your SMTP configuration."
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue