diff --git a/pkg/email/email.go b/pkg/email/email.go index 44741b2..245a0b2 100644 --- a/pkg/email/email.go +++ b/pkg/email/email.go @@ -18,6 +18,13 @@ const ( delimeter = "**=myohmy689407924327" ) +type EmailMessage struct { + To string + Subject string + Body string + Attachments []EmailAttachment +} + type SMTPClientIface interface { StartTLS(*tls.Config) error Auth(a smtp.Auth) error @@ -341,3 +348,16 @@ func (m message) withAttachments(body string, attachments []EmailAttachment) ([] message.WriteString("--" + delimeter + "--") // End the message return message.Bytes(), nil } + +type EmailAttachment struct { + File io.Reader + Title string +} + +func (e EmailAttachment) ReadContent() ([]byte, error) { + bts, err := io.ReadAll(e.File) + if err != nil { + return nil, fmt.Errorf("error loading attachment: %s", err) + } + return bts, nil +} diff --git a/pkg/email/message.go b/pkg/email/message.go deleted file mode 100644 index 16bcd08..0000000 --- a/pkg/email/message.go +++ /dev/null @@ -1,26 +0,0 @@ -package email - -import ( - "fmt" - "io" -) - -type EmailMessage struct { - To string - Subject string - Body string - Attachments []EmailAttachment -} - -type EmailAttachment struct { - File io.Reader - Title string -} - -func (e EmailAttachment) ReadContent() ([]byte, error) { - bts, err := io.ReadAll(e.File) - if err != nil { - return nil, fmt.Errorf("error loading attachment: %s", err) - } - return bts, nil -}