Skip to content

Commit

Permalink
Merge pull request #301 from coaidev/zmh-program/fix-smtp-compatibility
Browse files Browse the repository at this point in the history
Fix SMTP compatibility issues to support office365 provider
  • Loading branch information
zmh-program authored Dec 3, 2024
2 parents 928319a + 7a467e6 commit eb44490
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions utils/smtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,33 @@ func (s *SmtpPoster) SendMail(to string, subject string, body string) error {
dialer.SSL = true
}

// outlook starttls policy
if strings.Contains(s.Host, "outlook") {
// Specific handling for different providers
switch {
case strings.Contains(s.Host, "outlook"):
dialer.TLSConfig = &tls.Config{
InsecureSkipVerify: false,
ServerName: s.Host,
}
case strings.Contains(s.Host, "qq"):
dialer.TLSConfig = &tls.Config{
InsecureSkipVerify: true,
ServerName: s.Host,
}
case strings.Contains(s.Host, "office365"):
dialer.TLSConfig = &tls.Config{
InsecureSkipVerify: false,
ServerName: s.Host,
}
case strings.Contains(s.Host, "resend"):
dialer.TLSConfig = &tls.Config{
InsecureSkipVerify: true,
ServerName: s.Host,
}
case strings.Contains(s.Host, "tencent"):
dialer.TLSConfig = &tls.Config{
InsecureSkipVerify: true,
ServerName: s.Host,
}
}

if err := dialer.DialAndSend(message); err != nil {
Expand Down

0 comments on commit eb44490

Please sign in to comment.