mattjackson220 commented on a change in pull request #3534: TP Delivery Service 
Generate SSL update, new letsencrypt generate and…
URL: https://github.com/apache/trafficcontrol/pull/3534#discussion_r335720248
 
 

 ##########
 File path: traffic_ops/traffic_ops_golang/api/api.go
 ##########
 @@ -786,3 +792,81 @@ func AddUserToReq(r *http.Request, u auth.CurrentUser) {
        ctx = context.WithValue(ctx, auth.CurrentUserKey, u)
        *r = *r.WithContext(ctx)
 }
+
+func SendEmail(config config.Config, header string, data interface{}, 
templateFile string, toEmail string) error {
+       email := rfc.EmailAddress{
+               Address: mail.Address{Name: "", Address: toEmail},
+       }
+
+       msgBodyBuffer, err := parseTemplate(templateFile, data)
+       if err != nil {
+               return err
+       }
+       msg := append([]byte(header), msgBodyBuffer.Bytes()...)
+
+       int, userError, systemError := SendMail(email, msg, &config)
+       if userError != nil {
+               return errors.New("Failed to send email: " + userError.Error())
+       }
+       if systemError != nil {
+               return errors.New("Failed to send email: " + userError.Error())
 
 Review comment:
   done. returned standard code, user error, and system error then handled that 
when the call is made.  Updated to be named SendEmailFromTemplate to be more 
clear on the need for this func.  it calls the general SendMail func in it, but 
it parses and updates a template first

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to