浏览代码

Implemented Send() function

Jordan 11 年之前
父节点
当前提交
10f76c47f9
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      email.go

+ 5 - 2
email.go

@@ -53,8 +53,11 @@ func (e *Email) Bytes() []byte {
 }
 
 //Send an email using the given host and SMTP auth (optional)
-func (e *Email) Send(addr string, a smtp.Auth) {
-
+//This function merges the To, Cc, and Bcc fields and calls the smtp.SendMail function using the Email.Bytes() output as the message
+func (e *Email) Send(addr string, a smtp.Auth) error {
+	// Merge the To, Cc, and Bcc fields
+	to := append(append(e.To, e.Cc...), e.Bcc...)
+	return smtp.SendMail(addr, a, e.From, to, e.Bytes())
 }
 
 //Attachment is a struct representing an email attachment.