From 5293ae1221988d5cd0329d2a980612fb7e4df3a7 Mon Sep 17 00:00:00 2001 From: Gogs Date: Thu, 19 Feb 2015 10:47:05 +0300 Subject: [PATCH 1/2] Fix: 504 5.5.2 : Helo command rejected --- modules/mailer/mailer.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/mailer/mailer.go b/modules/mailer/mailer.go index 6a23e5d09ea..57400e73fc2 100644 --- a/modules/mailer/mailer.go +++ b/modules/mailer/mailer.go @@ -10,6 +10,7 @@ import ( "net" "net/mail" "net/smtp" + "os" "strings" "github.com/gogits/gogs/modules/log" @@ -95,6 +96,12 @@ func sendMail(settings *setting.Mailer, recipients []string, msgContent []byte) return err } + hostname, err := os.Hostname() + if err != nil { + return err + } + client.Hello(hostname) + // If not using SMTPS, alway use STARTTLS if available hasStartTLS, _ := client.Extension("STARTTLS") if !isSecureConn && hasStartTLS { From 2f1369c6147b51d0c5f82a3d236d69ac100ef8e8 Mon Sep 17 00:00:00 2001 From: Gogs Date: Fri, 20 Feb 2015 10:12:27 +0300 Subject: [PATCH 2/2] add error for hello func --- modules/mailer/mailer.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/mailer/mailer.go b/modules/mailer/mailer.go index 57400e73fc2..fc6ec2fa867 100644 --- a/modules/mailer/mailer.go +++ b/modules/mailer/mailer.go @@ -100,7 +100,10 @@ func sendMail(settings *setting.Mailer, recipients []string, msgContent []byte) if err != nil { return err } - client.Hello(hostname) + + if err = client.Hello(hostname); err != nil { + return err + } // If not using SMTPS, alway use STARTTLS if available hasStartTLS, _ := client.Extension("STARTTLS")