Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions gomail.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"io/ioutil"
"mime"
"path/filepath"
"sync"
"time"

"gopkg.in/alexcesaro/quotedprintable.v2"
Expand Down Expand Up @@ -131,8 +130,7 @@ func (msg *Message) SetAddressHeader(field, address, name string) {

// FormatAddress formats an address and a name as a valid RFC 5322 address.
func (msg *Message) FormatAddress(address, name string) string {
buf := getBuffer()
defer putBuffer(buf)
buf := new(bytes.Buffer)

if !quotedprintable.NeedsEncoding(name) {
quote(buf, name)
Expand Down Expand Up @@ -314,21 +312,3 @@ func encodeHeader(enc *quotedprintable.HeaderEncoder, value string) string {

return enc.Encode(value)
}

var bufPool = sync.Pool{
New: func() interface{} {
return new(bytes.Buffer)
},
}

func getBuffer() *bytes.Buffer {
return bufPool.Get().(*bytes.Buffer)
}

func putBuffer(buf *bytes.Buffer) {
if buf.Len() > 1024 {
return
}
buf.Reset()
bufPool.Put(buf)
}
4 changes: 2 additions & 2 deletions mailer.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gomail

import (
"bytes"
"crypto/tls"
"errors"
"fmt"
Expand Down Expand Up @@ -124,8 +125,7 @@ func (m *Mailer) Send(msg *Message) error {
}

func flattenHeader(msg *mail.Message, bcc string) []byte {
buf := getBuffer()
defer putBuffer(buf)
buf := new(bytes.Buffer)

for field, value := range msg.Header {
if field != "Bcc" {
Expand Down