Skip to content

Commit

Permalink
fix: use OS hostname for SMTP EHLO message
Browse files Browse the repository at this point in the history
  • Loading branch information
stonith404 committed Jan 24, 2025
1 parent 2884021 commit 47c39f6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions backend/internal/service/email_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"net"
"net/smtp"
"net/textproto"
"os"
ttemplate "text/template"
"time"
)
Expand Down Expand Up @@ -117,8 +118,12 @@ func SendEmail[V any](srv *EmailService, toEmail email.Address, template email.T
}
defer client.Close()

if err := client.Hello(common.EnvConfig.Host); err != nil {
return fmt.Errorf("failed to say hello to SMTP server: %w", err)
// Set the hello message manually as for example Google rejects the default "localhost" value
hostname, err := os.Hostname()
if err == nil {
if err := client.Hello(hostname); err != nil {
return fmt.Errorf("failed to say hello to SMTP server: %w", err)
}
}

smtpUser := srv.appConfigService.DbConfig.SmtpUser.Value
Expand Down

0 comments on commit 47c39f6

Please sign in to comment.