@@ -71,22 +71,22 @@ func (service *Service) Send(message string, params *types.Params) error {
7171 return fail (FailApplySendParams , err )
7272 }
7373
74- client , err := getClientConnection (service .config )
74+ client , err := getClientConnection (service .config , config . Encryption )
7575 if err != nil {
7676 return fail (FailGetSMTPClient , err )
7777 }
7878
7979 return service .doSend (client , message , & config )
8080}
8181
82- func getClientConnection (config * Config ) (* smtp.Client , error ) {
82+ func getClientConnection (config * Config , encryption encMethod ) (* smtp.Client , error ) {
8383
8484 var conn net.Conn
8585 var err error
8686
8787 addr := fmt .Sprintf ("%s:%d" , config .Host , config .Port )
8888
89- if useImplicitTLS (config . Encryption , config .Port ) {
89+ if useImplicitTLS (encryption , config .Port ) {
9090 conn , err = tls .Dial ("tcp" , addr , & tls.Config {
9191 ServerName : config .Host ,
9292 })
@@ -206,7 +206,7 @@ func (service *Service) sendToRecipient(client *smtp.Client, toAddress string, c
206206 return fail (FailOpenDataStream , err )
207207 }
208208
209- if err := writeHeaders (wc , service .getHeaders (toAddress , config . Subject )); err != nil {
209+ if err := writeHeaders (wc , service .getHeaders (toAddress , config )); err != nil {
210210 return err
211211 }
212212
@@ -228,9 +228,7 @@ func (service *Service) sendToRecipient(client *smtp.Client, toAddress string, c
228228 return nil
229229}
230230
231- func (service * Service ) getHeaders (toAddress string , subject string ) map [string ]string {
232- conf := service .config
233-
231+ func (service * Service ) getHeaders (toAddress string , conf * Config ) map [string ]string {
234232 var contentType string
235233 if conf .UseHTML {
236234 contentType = fmt .Sprintf (contentMultipart , service .multipartBoundary )
@@ -239,7 +237,7 @@ func (service *Service) getHeaders(toAddress string, subject string) map[string]
239237 }
240238
241239 return map [string ]string {
242- "Subject" : subject ,
240+ "Subject" : conf . Subject ,
243241 "Date" : time .Now ().Format (time .RFC1123Z ),
244242 "To" : toAddress ,
245243 "From" : fmt .Sprintf ("%s <%s>" , conf .FromName , conf .FromAddress ),
0 commit comments