@@ -31,7 +31,7 @@ type EmailLogic struct{}
31
31
var DefaultEmail = EmailLogic {}
32
32
33
33
// SendMail 发送电子邮件
34
- func (EmailLogic ) SendMail (subject , content string , tos []string ) (err error ) {
34
+ func (EmailLogic ) SendMail (subject , content string , tos []string , isRegs ... bool ) (err error ) {
35
35
emailConfig , _ := config .ConfigFile .GetSection ("email" )
36
36
37
37
fromEmail := emailConfig ["from_email" ]
@@ -40,16 +40,19 @@ func (EmailLogic) SendMail(subject, content string, tos []string) (err error) {
40
40
smtpHost := emailConfig ["smtp_host" ]
41
41
smtpPort := emailConfig ["smtp_port" ]
42
42
43
- for _ , to := range tos {
44
- if strings .HasSuffix (to , "163.com" ) || strings .HasSuffix (to , "126.com" ) {
45
- email163Config , _ := config .ConfigFile .GetSection ("email.163" )
46
- fromEmail = email163Config ["from_email" ]
47
- smtpUsername = email163Config ["smtp_username" ]
48
- smtpPassword = email163Config ["smtp_password" ]
49
- smtpHost = email163Config ["smtp_host" ]
50
- smtpPort = email163Config ["smtp_port" ]
51
-
52
- break
43
+ // 注册才区别使用 163,尽可能确保能收到
44
+ if len (isRegs ) > 0 && isRegs [0 ] {
45
+ for _ , to := range tos {
46
+ if strings .HasSuffix (to , "163.com" ) || strings .HasSuffix (to , "126.com" ) {
47
+ email163Config , _ := config .ConfigFile .GetSection ("email.163" )
48
+ fromEmail = email163Config ["from_email" ]
49
+ smtpUsername = email163Config ["smtp_username" ]
50
+ smtpPassword = email163Config ["smtp_password" ]
51
+ smtpHost = email163Config ["smtp_host" ]
52
+ smtpPort = email163Config ["smtp_port" ]
53
+
54
+ break
55
+ }
53
56
}
54
57
}
55
58
@@ -104,7 +107,7 @@ func (self EmailLogic) SendActivateMail(email, uuid string, isHttps ...bool) {
104
107
感谢您选择了` + WebsiteSetting .Name + `,请点击下面的地址激活你在` + WebsiteSetting .Name + `的帐号(有效期4小时):<br/><br/>
105
108
<a href="` + activeUrl + `">` + activeUrl + `</a><br/><br/>
106
109
<div style="text-align:right;">©` + global .App .Copyright + ` ` + WebsiteSetting .Name + `</div>`
107
- self .SendMail (WebsiteSetting .Name + "帐号激活邮件" , content , []string {email })
110
+ self .SendMail (WebsiteSetting .Name + "帐号激活邮件" , content , []string {email }, true )
108
111
}
109
112
110
113
func (EmailLogic ) genActivateSign (email , uuid string , ts int64 ) string {
@@ -131,7 +134,7 @@ func (self EmailLogic) SendResetpwdMail(email, uuid string, isHttps ...bool) {
131
134
如果您有任何疑问,可以回复这封邮件向我们提问。谢谢!<br/><br/>
132
135
133
136
<div style="text-align:right;">©` + global .App .Copyright + ` ` + WebsiteSetting .Name + `</div>`
134
- self .SendMail ("【" + WebsiteSetting .Name + "】重设密码 " , content , []string {email })
137
+ self .SendMail ("【" + WebsiteSetting .Name + "】重设密码 " , content , []string {email }, true )
135
138
}
136
139
137
140
// 自定义模板函数
0 commit comments