Skip to content

Commit 2a79407

Browse files
committed
Added in boundary string, plain text
1 parent fcef703 commit 2a79407

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![made-with-Go](https://img.shields.io/badge/Made%20with-Go-1f425f.svg)](http://golang.org)
55
[![Go Report Card](https://goreportcard.com/badge/github.com/ainsleyclark/go-mail)](https://goreportcard.com/report/github.com/ainsleyclark/go-mail)
66
[![Test](https://github.com/ainsleyclark/go-mail/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/ainsleyclark/go-mail/actions/workflows/test.yml)
7-
[![codecov](https://codecov.io/gh/ainsleyclark/go-mail/branch/master/graph/badge.svg?token=K27L8LS7DA)](https://codecov.io/gh/ainsleyclark/go-mail)
7+
[![codecov](https://codecov.io/gh/ainsleyclark/go-mail/branch/main/graph/badge.svg?token=1ZI9R34CHQ)](https://codecov.io/gh/ainsleyclark/go-mail)
88
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/ainsleyclark/go-mail)
99
[![Twitter Handle](https://img.shields.io/twitter/follow/ainsleydev)](https://twitter.com/ainsleydev)
1010
</div>

drivers/smtp.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ func (m *smtpClient) getTo(t *mail.Transmission) []string {
9292
// Processes the mail.Transmission and returns the bytes for
9393
// sending. Mime types are set dependent on the
9494
// content passed.
95+
// See: https://gist.github.com/tylermakin/d820f65eb3c9dd98d58721c7fb1939a8?permalink_comment_id=2703291
9596
func (m *smtpClient) bytes(t *mail.Transmission) []byte {
9697
buf := bytes.NewBuffer(nil)
9798

@@ -116,18 +117,20 @@ func (m *smtpClient) bytes(t *mail.Transmission) []byte {
116117
buf.WriteString(fmt.Sprintf("CC: %s\n", strings.Join(t.CC, ",")))
117118
}
118119

120+
buf.WriteString("\n")
121+
119122
if t.PlainText != "" {
120123
buf.WriteString(fmt.Sprintf("--%s\r\n", boundary))
121124
buf.WriteString("Content-Transfer-Encoding: quoted-printable\r\n")
122125
buf.WriteString("Content-Type: text/plain; charset=UTF-8\r\n")
123-
buf.WriteString(fmt.Sprintf("\r\n%s\r\n", strings.TrimSpace(t.PlainText)))
126+
buf.WriteString(fmt.Sprintf("\r\n%s\r\n\n", strings.TrimSpace(t.PlainText)))
124127
}
125128

126129
if t.HTML != "" {
127130
buf.WriteString(fmt.Sprintf("--%s\r\n", boundary))
128131
buf.WriteString("Content-Transfer-Encoding: quoted-printable\r\n")
129132
buf.WriteString("Content-Type: text/html; charset=UTF-8\r\n")
130-
buf.WriteString(fmt.Sprintf("\r\n%s\r\n", t.HTML))
133+
buf.WriteString(fmt.Sprintf("\r\n%s\r\n\n", t.HTML))
131134
}
132135

133136
if t.HasAttachments() {
@@ -141,5 +144,7 @@ func (m *smtpClient) bytes(t *mail.Transmission) []byte {
141144
buf.WriteString("--")
142145
}
143146

147+
buf.WriteString(fmt.Sprintf("--%s--\n", boundary))
148+
144149
return buf.Bytes()
145150
}

0 commit comments

Comments
 (0)