mirror of
https://github.com/nabbar/golib.git
synced 2025-10-06 16:27:02 +08:00

- smtp : refactor smtp packgage and allow connection context for smtp - mailer : add package for templating mail (using hermes lib) - mail : add package to format mal with header to be send to smtp (using lib smple mail) Add function in package : - errors : add function to retireve a map of minimal error code and package path of the getMessage function - version : add function to get root path of package (still existing but not return before this function) - ioutils : add function to expand bytes.buffer as io.ReadCloser interface
45 lines
928 B
Go
45 lines
928 B
Go
package mail
|
|
|
|
type Encoding uint8
|
|
|
|
const (
|
|
// EncodingNone turns off encoding on the message body
|
|
EncodingNone Encoding = iota
|
|
|
|
// EncodingBinary is equal to EncodingNone, but string is set to binrary instead of none
|
|
EncodingBinary
|
|
|
|
// EncodingBase64 sets the message body encoding to base64
|
|
EncodingBase64
|
|
|
|
// EncodingQuotedPrintable sets the message body encoding to quoted-printable
|
|
EncodingQuotedPrintable
|
|
)
|
|
|
|
func (e Encoding) String() string {
|
|
switch e {
|
|
case EncodingBinary:
|
|
return "Binary"
|
|
case EncodingBase64:
|
|
return "Base 64"
|
|
case EncodingQuotedPrintable:
|
|
return "Quoted Printable"
|
|
case EncodingNone:
|
|
return "None"
|
|
}
|
|
return EncodingNone.String()
|
|
}
|
|
|
|
func (e Encoding) getEncoding() string {
|
|
switch e {
|
|
case EncodingNone, EncodingBinary:
|
|
return "binary"
|
|
case EncodingBase64:
|
|
return "base64"
|
|
case EncodingQuotedPrintable:
|
|
return "quoted-printable"
|
|
}
|
|
|
|
return EncodingNone.getEncoding()
|
|
}
|