You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is an issue where if the template crashes, the gomail.Send(sender, msg) returns the error, therefore implying correct error handling, but the email is sent regardless of template execution.
I.e.: the html contains:
a class="button-3" href="{{.Data.ConfirmationLink}}"> Confirm Email
where Data is a map. the template is configured for "missingkey=error", so if Data does not contain this key, the function tmp.execute(w, mail) will return an error. However, the email will still be sent:
As seen, with the error log being:
{"level":"error","time":"2022-12-27T13:47:24+03:00","message":"Could not send email to "xxx": gomail: could not send email 1: template: emailConfirmation.html:110:53: executing "emailConfirmation.html" at <.Data.ConfirmationLink>: map has no entry for key "ConfirmationLink""}
I might be wrong in pointing this out, but in my opinion, if an error is found while executing the message template writer, the whole message should be discarded
The text was updated successfully, but these errors were encountered:
I should add, that executing the template beforehand is an option, and it certainly helps, but it means wasting memory and performance - you need an extra buffer for the mail and an extra execution time
This module isn't maintained anymore. It might be worth looking at go-mail which is actively maintained and supports text.Template/html.Template out of the box. The syntax is very similar, so a switch should be faily simple.
This module isn't maintained anymore. It might be worth looking at go-mail which is actively maintained and supports text.Template/html.Template out of the box. The syntax is very similar, so a switch should be faily simple.
Thank you! managed to switch in a blink of an eye. The only thing is - got some problems with SMTPAuthLogin there. maybe would open a request later, not a pressing issue - plain works!
There is an issue where if the template crashes, the gomail.Send(sender, msg) returns the error, therefore implying correct error handling, but the email is sent regardless of template execution.
I.e.: the html contains:
a class="button-3" href="{{.Data.ConfirmationLink}}"> Confirm Email
where Data is a map. the template is configured for "missingkey=error", so if Data does not contain this key, the function
tmp.execute(w, mail)
will return an error. However, the email will still be sent:As seen, with the error log being:
{"level":"error","time":"2022-12-27T13:47:24+03:00","message":"Could not send email to "xxx": gomail: could not send email 1: template: emailConfirmation.html:110:53: executing "emailConfirmation.html" at <.Data.ConfirmationLink>: map has no entry for key "ConfirmationLink""}
I might be wrong in pointing this out, but in my opinion, if an error is found while executing the message template writer, the whole message should be discarded
The text was updated successfully, but these errors were encountered: