We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 30d3aa0 commit 4078ba1Copy full SHA for 4078ba1
1 file changed
emails/server.go
@@ -4,6 +4,7 @@ import (
4
"errors"
5
"io"
6
"strconv"
7
+ "sync"
8
"time"
9
10
"github.com/emersion/go-sasl"
@@ -20,23 +21,28 @@ type Backend struct {
20
21
username string
22
password string
23
Emails chan Email
24
+ Mutex sync.Mutex
25
}
26
27
func (bkd *Backend) NewSession(c *smtp.Conn) (smtp.Session, error) {
- return &Session{bkd: bkd}, nil
28
+ return &Session{bkd: bkd}, nil
29
30
31
func (bkd *Backend) ClearQueue() {
32
+ bkd.Mutex.Lock()
33
for len(bkd.Emails) != 0 {
34
<-bkd.Emails
35
36
+ bkd.Mutex.Unlock()
37
38
39
func (bkd *Backend) AddEmail(email Email) {
40
41
if len(bkd.Emails) == cap(bkd.Emails) {
42
43
44
bkd.Emails <- email
45
46
47
48
type Session struct {
0 commit comments