-
-
Notifications
You must be signed in to change notification settings - Fork 80
Closed
Labels
bugSomething isn't workingSomething isn't workingmore details neededThis issue is currently waiting for more details from the reporterThis issue is currently waiting for more details from the reporter
Description
Description
I copied this code from the documentation and made some adjustments, mainly changing the SMTP server to smtp.qq.com, but I'm encountering an error.
package main
import (
"log"
"github.com/wneessen/go-mail"
)
func main() {
host := "[email protected]"
message := mail.NewMsg()
if err := message.From(host); err != nil {
log.Fatalf("failed to set From address: %s", err)
}
if err := message.To("[email protected]"); err != nil {
log.Fatalf("failed to set To address: %s", err)
}
message.Subject("This is my first mail with go-mail!")
message.SetBodyString(mail.TypeTextPlain, "Do you like this mail? I certainly do!")
client, err := mail.NewClient("smtp.qq.com",
mail.WithPort(465),
mail.WithSSL(),
mail.WithSMTPAuth(mail.SMTPAuthPlain),
mail.WithUsername(host),
mail.WithPassword("xxx"),
)
if err != nil {
log.Fatalf("failed to create mail client: %s", err)
}
if err := client.DialAndSend(message); err != nil {
log.Fatalf("failed to send mail: %s", err)
}
log.Println("Mail sent successfully!")
}To Reproduce
When executing go run main.go, the following error occurs:
2025/04/02 16:11:07 failed to send mail: send failed: sending SMTP RESET command: not connected to SMTP server, affected message ID: [email protected]
Despite the error, I still received the email. Is there a way to fix this issue? Or can this error be safely ignored?
Expected behaviour
Email sent successfully with no errors returned
Screenshots
Attempted Fixes
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingmore details neededThis issue is currently waiting for more details from the reporterThis issue is currently waiting for more details from the reporter