-
Notifications
You must be signed in to change notification settings - Fork 591
Open
Description
When I use go 1.16, I get an error:
2025/02/26 19:10:27 邮件发送失败:gomail: could not send email 1: 502 5.3.3 Command not implemented
exit status 1
When I use go 1.15, I can send normally:
$ g use 1.15
go version go1.15 windows/amd64
$ go run main.go
邮件发送成功!
My code is as follows:
package main
import (
"fmt"
"gopkg.in/gomail.v2"
"log"
"crypto/tls"
)
func SendEmail() {
// 邮件内容
from := "apialarm@xxx.com" // 发件人邮箱
password := "xxxxxxxxx" // 发件人邮箱密码
to := "xxxx.lv01@xxxxx.com" // 收件人邮箱
subject := "邮件发送测试"
body := "这是一个简单的邮件测试内容xxaaa!"
// 创建邮件对象
m := gomail.NewMessage()
// 设置发件人、收件人和邮件主题
m.SetHeader("From", from)
m.SetHeader("To", to)
m.SetHeader("Subject", subject)
// 设置邮件内容
m.SetBody("text/plain", body)
// 创建SMTP客户端
d := gomail.NewDialer("email.xxxx.com", 25, from, password)
d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
// 发送邮件
if err := d.DialAndSend(m); err != nil {
log.Fatal("邮件发送失败:", err)
} else {
fmt.Println("邮件发送成功!")
}
}
func main() {
SendEmail()
}
What is the reason?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels