refactor: remove file

This commit is contained in:
urko 2025-03-19 15:45:33 +01:00
parent 2028190971
commit 9844ebc65d
2 changed files with 20 additions and 26 deletions

View File

@ -18,6 +18,13 @@ const (
delimeter = "**=myohmy689407924327" delimeter = "**=myohmy689407924327"
) )
type EmailMessage struct {
To string
Subject string
Body string
Attachments []EmailAttachment
}
type SMTPClientIface interface { type SMTPClientIface interface {
StartTLS(*tls.Config) error StartTLS(*tls.Config) error
Auth(a smtp.Auth) error Auth(a smtp.Auth) error
@ -341,3 +348,16 @@ func (m message) withAttachments(body string, attachments []EmailAttachment) ([]
message.WriteString("--" + delimeter + "--") // End the message message.WriteString("--" + delimeter + "--") // End the message
return message.Bytes(), nil 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
}

View File

@ -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
}