feat: add mail service for managing email configurations, generating accounts, and fetching emails with verification code support.
This commit is contained in:
@@ -363,21 +363,30 @@ func (m *Client) WaitForCode(email string, timeout time.Duration) (string, error
|
||||
for _, mail := range emails {
|
||||
subject := strings.ToLower(mail.Subject)
|
||||
// 匹配多种可能的验证码邮件主题
|
||||
// 包括 "Your ChatGPT code is 016547" 格式
|
||||
isCodeEmail := strings.Contains(subject, "code") ||
|
||||
strings.Contains(subject, "verify") ||
|
||||
strings.Contains(subject, "verification") ||
|
||||
strings.Contains(subject, "openai") ||
|
||||
strings.Contains(subject, "confirm")
|
||||
strings.Contains(subject, "confirm") ||
|
||||
strings.Contains(subject, "chatgpt")
|
||||
|
||||
if !isCodeEmail {
|
||||
continue
|
||||
}
|
||||
|
||||
// 优先从标题中提取验证码 (如 "Your ChatGPT code is 016547")
|
||||
matches := codeRegex.FindStringSubmatch(mail.Subject)
|
||||
if len(matches) >= 2 {
|
||||
return matches[1], nil
|
||||
}
|
||||
|
||||
// 如果标题中没有,从内容中提取
|
||||
content := mail.Content
|
||||
if content == "" {
|
||||
content = mail.Text
|
||||
}
|
||||
matches := codeRegex.FindStringSubmatch(content)
|
||||
matches = codeRegex.FindStringSubmatch(content)
|
||||
if len(matches) >= 2 {
|
||||
return matches[1], nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user