You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2019/11/06 21:07:14 UTC

[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #4077: updated SMTP to use Login Auth

rawlinp commented on a change in pull request #4077: updated SMTP to use Login Auth
URL: https://github.com/apache/trafficcontrol/pull/4077#discussion_r343327543
 
 

 ##########
 File path: traffic_ops/traffic_ops_golang/api/api.go
 ##########
 @@ -410,8 +410,11 @@ func SendMail(to rfc.EmailAddress, msg []byte, cfg *config.Config) (int, error,
 	if !cfg.SMTP.Enabled {
 		return http.StatusInternalServerError, nil, errors.New("SMTP is not enabled; mail cannot be sent")
 	}
-	auth := smtp.PlainAuth("", cfg.SMTP.User, cfg.SMTP.Password, strings.Split(cfg.SMTP.Address, ":")[0])
-	err := smtp.SendMail(cfg.SMTP.Address, auth, cfg.ConfigTO.EmailFrom.String(), []string{to.String()}, msg)
+	var auth smtp.Auth
+	if cfg.SMTP.User != "" {
+		auth = LoginAuth("", cfg.SMTP.User, cfg.SMTP.Password, strings.Split(cfg.SMTP.Address, ":")[0])
+	}
+	err := smtp.SendMail(cfg.SMTP.Address, auth, cfg.ConfigTO.EmailFrom.Address.Address, []string{to.Address.Address}, msg)
 
 Review comment:
   Does a nil `smtp.Auth` var work with `smtp.SendMail` still? I.e. smtp is enabled, but the user == `""`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services