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/09/23 03:06:08 UTC

[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #3929: Rewrote /user/reset_password to Go

ocket8888 commented on a change in pull request #3929: Rewrote /user/reset_password to Go
URL: https://github.com/apache/trafficcontrol/pull/3929#discussion_r326938865
 
 

 ##########
 File path: traffic_ops/traffic_ops_golang/api/api.go
 ##########
 @@ -369,6 +371,33 @@ func (inf *APIInfo) Close() {
 	}
 }
 
+// SendMail is a convenience method used to call SendMail using an APIInfo structure's configuration.
+func (inf *APIInfo) SendMail(to rfc.EmailAddress, msg []byte) (int, error, error) {
+	return SendMail(to, msg, inf.Config)
+}
+
+// SendMail sends an email msg to the address identified by to. The msg parameter should be an
+// RFC822-style email with headers first, a blank line, and then the message body. The lines of msg
+// should be CRLF terminated. The msg headers should usually include fields such as "From", "To",
+// "Subject", and "Cc". Sending "Bcc" messages is accomplished by including an email address in the
+// to parameter but not including it in the msg headers.
+// The cfg parameter is used to set things like the "From" field, as well as for connection
+// and authentication with an external SMTP server.
+// SendMail returns (in order) an HTTP status code, a user-friendly error, and an error fit for
+// logging to system error logs. If either the user or system error is non-nil, the operation failed,
+// and the HTTP status code indicates the type of failure.
+func SendMail(to rfc.EmailAddress, msg []byte, cfg *config.Config) (int, error, error) {
+	if !cfg.SMTP.Enabled {
+		return http.StatusServiceUnavailable, errors.New("SMTP is not enabled!"), nil
 
 Review comment:
   Nah, I don't think so. There's (presumably) nothing wrong with the request, it's just that the server is incapable of answering the request because of an absentee service.

----------------------------------------------------------------
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