-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcourier.go
More file actions
34 lines (30 loc) · 815 Bytes
/
courier.go
File metadata and controls
34 lines (30 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package courier
import (
"context"
"github.com/beeceej/courier/mail"
"github.com/beeceej/courier/pb"
)
// Courier is the server object for the courier grpc interface
type Courier struct{}
// Send is the rpc call to send mail
func (s *Courier) Send(ctx context.Context, in *pb.SendBody) (*pb.Response, error) {
mailer := mail.Mail{
Message: *mail.New(
mail.CC(in.GetCc()...),
mail.BCC(in.GetBcc()...),
mail.To(in.GetRecipients()...),
mail.From(in.GetSender()),
mail.Subject(in.GetSubject()),
mail.Body(in.GetBodyText()),
mail.BodyType(in.GetBodyType()),
mail.Attachments(in.GetAttachments()...),
),
SMTP: mail.SMTP{
Host: SMTPHost,
Password: SMTPPassword,
Port: int(SMTPServerPort),
},
}
mailer.Send()
return &pb.Response{Status: pb.Status_Success}, nil
}