2017-12-02 2 views
0

golang을 사용하여 multipart-email를 보내려고하고 있지만 어떻게 만들지 알 수 없습니다. 멀티 파트 패키지가 있다는 것을 알고 있지만 사용 방법에 대한 예제가 없습니다.mutlipart go go

이미 mailyak 라이브러리를 사용해 보았지만 제대로 작동하지 않습니다. 그래서, 어떻게 일반 골란 smtp/multipart 패키지 multipart 이메일을 만들 수 있습니까?

메일에는 HTML과 일반 텍스트 부분이 있어야합니다.

+1

을하실 수 있습니다. –

답변

0

당신은 다중 패키지의 사용 (예를 들어 https://golang.org/src/mime/multipart/writer_test.go)에서 [테스트]를 참조하십시오이 패키지를 https://github.com/scorredoira/email

// compose the message 
m := email.NewMessage("Hi", "this is the body") 
m.From = mail.Address{Name: "From", Address: "[email protected]"} 
m.To = []string{"[email protected]"} 

// add attachments 
if err := m.Attach("email.go"); err != nil { 
    log.Fatal(err) 
} 

// send it 
auth := smtp.PlainAuth("", "[email protected]", "pwd", "smtp.zoho.com") 
if err := email.Send("smtp.zoho.com:587", auth, m); err != nil { 
    log.Fatal(err) 
} 
관련 문제