Lowered Go version requirement from 1.5 to 1.2
This commit is contained in:
parent
b01506efc6
commit
3346e955b2
|
@ -4,7 +4,7 @@
|
|||
|
||||
Gomail is a very simple and powerful package to send emails.
|
||||
|
||||
It requires Go 1.3 or newer.
|
||||
It requires Go 1.2 or newer.
|
||||
|
||||
|
||||
## Features
|
||||
|
|
|
@ -6,7 +6,6 @@ package gomail
|
|||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"mime"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
@ -20,7 +19,7 @@ type Message struct {
|
|||
embedded []*File
|
||||
charset string
|
||||
encoding Encoding
|
||||
hEncoder mime.WordEncoder
|
||||
hEncoder mimeEncoder
|
||||
buf bytes.Buffer
|
||||
}
|
||||
|
||||
|
@ -43,9 +42,9 @@ func NewMessage(settings ...MessageSetting) *Message {
|
|||
m.applySettings(settings)
|
||||
|
||||
if m.encoding == Base64 {
|
||||
m.hEncoder = mime.BEncoding
|
||||
m.hEncoder = bEncoding
|
||||
} else {
|
||||
m.hEncoder = mime.QEncoding
|
||||
m.hEncoder = qEncoding
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -150,7 +149,7 @@ func (m *Message) FormatAddress(address, name string) string {
|
|||
}
|
||||
m.buf.WriteByte('"')
|
||||
} else if hasSpecials(name) {
|
||||
m.buf.WriteString(mime.BEncoding.Encode(m.charset, name))
|
||||
m.buf.WriteString(bEncoding.Encode(m.charset, name))
|
||||
} else {
|
||||
m.buf.WriteString(enc)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
// +build go1.5
|
||||
|
||||
package gomail
|
||||
|
||||
import (
|
||||
"mime"
|
||||
"mime/quotedprintable"
|
||||
)
|
||||
|
||||
var newQPWriter = quotedprintable.NewWriter
|
||||
|
||||
type mimeEncoder struct {
|
||||
mime.WordEncoder
|
||||
}
|
||||
|
||||
var (
|
||||
bEncoding = mimeEncoder{mime.BEncoding}
|
||||
qEncoding = mimeEncoder{mime.QEncoding}
|
||||
)
|
|
@ -0,0 +1,16 @@
|
|||
// +build !go1.5
|
||||
|
||||
package gomail
|
||||
|
||||
import "gopkg.in/alexcesaro/quotedprintable.v3"
|
||||
|
||||
var newQPWriter = quotedprintable.NewWriter
|
||||
|
||||
type mimeEncoder struct {
|
||||
quotedprintable.WordEncoder
|
||||
}
|
||||
|
||||
var (
|
||||
bEncoding = mimeEncoder{quotedprintable.BEncoding}
|
||||
qEncoding = mimeEncoder{quotedprintable.QEncoding}
|
||||
)
|
|
@ -6,7 +6,6 @@ import (
|
|||
"io"
|
||||
"mime"
|
||||
"mime/multipart"
|
||||
"mime/quotedprintable"
|
||||
"path/filepath"
|
||||
"time"
|
||||
)
|
||||
|
@ -207,7 +206,7 @@ func (w *messageWriter) writeBody(f func(io.Writer) error, enc Encoding) {
|
|||
} else if enc == Unencoded {
|
||||
w.err = f(subWriter)
|
||||
} else {
|
||||
wc := quotedprintable.NewWriter(subWriter)
|
||||
wc := newQPWriter(subWriter)
|
||||
w.err = f(wc)
|
||||
wc.Close()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue