浏览代码

Close the file after attachment (#42)

ursc 7 年之前
父节点
当前提交
50fb9532f7
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      email.go

+ 2 - 0
email.go

@@ -229,6 +229,8 @@ func (e *Email) AttachFile(filename string) (a *Attachment, err error) {
 	if err != nil {
 		return
 	}
+	defer f.Close()
+
 	ct := mime.TypeByExtension(filepath.Ext(filename))
 	basename := filepath.Base(filename)
 	return e.Attach(f, basename, ct)