In the above example, the recipients passed to SendMail will be encoded and result in a 501 5.1.3 Bad recipient address syntax from any postfix server.
In my opinion, the expected behaviour of SetHeader is not to mutate the values passed as arguments.
Solution
The proposed change creates a new array of string of the same length as the header values passed in and fill it with the encoded values, therefore not touching the raw ones.
Problem
Arrays in Go are mutable. This method currently replaces all values passed to
SetHeader
by their encoded version.This can be problematic in a scenario that the array passed to
SetHeader
is reused somewhere else in the code.Ex :
In the above example, the recipients passed to
SendMail
will be encoded and result in a501 5.1.3 Bad recipient address syntax
from any postfix server.In my opinion, the expected behaviour of
SetHeader
is not to mutate the values passed as arguments.Solution
The proposed change creates a new array of string of the same length as the header values passed in and fill it with the encoded values, therefore not touching the raw ones.