go-gomail / gomail

The best way to send emails in Go.
MIT License
4.33k stars 573 forks source link

Export to []byte #15

Closed chrneumann closed 9 years ago

chrneumann commented 9 years ago

It would be nice to be able to export gomail.Message to []byte. I would suggest a function Raw() []byte on Message.

I could implement this and make a pull request.

alexcesaro commented 9 years ago

That's ok, thanks! Please name it Bytes() to be consistent with the standard library.

chrneumann commented 9 years ago

I decided to solve my problem by setting a custom SendMailFunc instead. Thanks anyway!

nvcnvn commented 9 years ago

Any hints to implement this feature? I really want to use this package to send mail with Amazon SES using raw data.

Thanks!

chrneumann commented 9 years ago

I'm not sure what you want to do, but you could try using a custom SendMailFunc.

chrneumann commented 9 years ago

For an example, see my SendMailFunc https://github.com/monsti/monsti/blob/master/api/service/monsti.go#L556 and its use here: https://github.com/monsti/monsti/blob/master/core/monsti-daemon/session.go#L144

nvcnvn commented 9 years ago

I think SendMailFunc quite different from my need. AWS allow you to post a raw email message to SES API via HTTP: http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-raw.html

alexcesaro commented 9 years ago

chrneumann is right, that's the best way to do it. A Message instance can represent different raw emails when the Bcc field is filled. So it cannot simply be exported to a slice of bytes.

Use a SendMailFunc instead.