@@ -2,9 +2,10 @@ package gomail
2
2
3
3
import (
4
4
"bufio"
5
+ "context"
5
6
"encoding/base64"
6
7
"fmt"
7
- "io/ioutil "
8
+ "io"
8
9
"log"
9
10
"strings"
10
11
@@ -13,11 +14,11 @@ import (
13
14
14
15
// postmarkInterface is an interface for Postmark/mocking
15
16
type postmarkInterface interface {
16
- SendEmail (email postmark.Email ) (postmark.EmailResponse , error )
17
+ SendEmail (ctx context. Context , email postmark.Email ) (postmark.EmailResponse , error )
17
18
}
18
19
19
20
// sendViaPostmark sends an email using the Postmark service
20
- func sendViaPostmark (client postmarkInterface , email * Email ) (err error ) {
21
+ func sendViaPostmark (ctx context. Context , client postmarkInterface , email * Email ) (err error ) {
21
22
22
23
// Create the email struct
23
24
postmarkEmail := postmark.Email {
@@ -73,7 +74,7 @@ func sendViaPostmark(client postmarkInterface, email *Email) (err error) {
73
74
// Read all content from the attachment
74
75
reader := bufio .NewReader (attachment .FileReader )
75
76
var content []byte
76
- if content , err = ioutil .ReadAll (reader ); err != nil {
77
+ if content , err = io .ReadAll (reader ); err != nil {
77
78
return
78
79
}
79
80
@@ -96,7 +97,7 @@ func sendViaPostmark(client postmarkInterface, email *Email) (err error) {
96
97
97
98
// Send the email
98
99
var resp postmark.EmailResponse
99
- if resp , err = client .SendEmail (postmarkEmail ); err != nil {
100
+ if resp , err = client .SendEmail (ctx , postmarkEmail ); err != nil {
100
101
return
101
102
}
102
103
0 commit comments