支持网易邮箱

This commit is contained in:
2022-12-01 14:35:55 +08:00
parent 8d5a2cdf20
commit 074b4bc24c
12 changed files with 10 additions and 7 deletions

BIN
bin/386

Binary file not shown.

BIN
bin/amd64

Binary file not shown.

BIN
bin/arm

Binary file not shown.

BIN
bin/arm64

Binary file not shown.

BIN
bin/mips

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/ppc64

Binary file not shown.

Binary file not shown.

View File

@@ -1,4 +1,4 @@
[global]
SEND_QQ = "1605227279@qq.com"; // 发送者QQ
MAIL_KEY = "yojgexjxmnktiife"; // 发送者QQ密钥
SMTP_SERVER = "smtp.qq.com:25"; // smtp服务器地址
SEND_MAIL = "yuling.niu@hohong.cn"; // 发送者QQ
MAIL_KEY = "9yZUCCphkRyuaPNj"; // 发送者QQ密钥
SMTP_SERVER = "smtphz.qiye.163.com:25"; // smtp服务器地址

11
main.go
View File

@@ -26,9 +26,11 @@ func PathExists(path string) (bool, error) {
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return false, err
}
@@ -36,6 +38,7 @@ func main() {
// 判断配置文件是否存在
INIFILE := GetCurrentDirectory() + "/" + "gomail.ini"
b, _ := PathExists(INIFILE)
if !b {
INIFILE = "/etc/gomail.ini"
}
@@ -47,7 +50,7 @@ func main() {
os.Exit(1)
}
SEND_QQ := cfg.Section("global").Key("SEND_QQ").String()
SEND_MAIL := cfg.Section("global").Key("SEND_MAIL").String()
MAIL_KEY := cfg.Section("global").Key("MAIL_KEY").String()
SMTP_SERVER := cfg.Section("global").Key("SMTP_SERVER").String()
@@ -62,7 +65,7 @@ func main() {
e := email.NewEmail()
// 设置 sender 发送方 的邮箱 此处可以填写自己的邮箱
e.From = SEND_QQ
e.From = SEND_MAIL
// 设置 receiver 接收方 的邮箱 此处也可以填写自己的邮箱, 就是自己发邮件给自己
e.To = []string{*To}
@@ -81,8 +84,8 @@ func main() {
host_sign := strings.Index(SMTP_SERVER, ":")
SMTP_SERVER_Host := SMTP_SERVER[0:(len(SMTP_SERVER) - len(SMTP_SERVER[host_sign:]))]
//设置服务器相关的配置
err := e.Send(SMTP_SERVER, smtp.PlainAuth("", SEND_QQ, MAIL_KEY, SMTP_SERVER_Host))
// 设置服务器相关的配置
err := e.Send(SMTP_SERVER, smtp.PlainAuth("", SEND_MAIL, MAIL_KEY, SMTP_SERVER_Host))
if err != nil {
log.Fatal(err)
}