1
0
Fork 1
mirror of https://github.com/hay-kot/homebox.git synced 2024-12-29 01:56:34 +00:00
homebox/backend/pkgs/mailer/message.go
2022-08-29 18:30:36 -08:00

56 lines
953 B
Go

package mailer
import "net/mail"
type Message struct {
Subject string
To mail.Address
From mail.Address
Body string
}
type MessageBuilder struct {
subject string
to mail.Address
from mail.Address
body string
}
func NewMessageBuilder() *MessageBuilder {
return &MessageBuilder{}
}
func (mb *MessageBuilder) Build() *Message {
return &Message{
Subject: mb.subject,
To: mb.to,
From: mb.from,
Body: mb.body,
}
}
func (mb *MessageBuilder) SetSubject(subject string) *MessageBuilder {
mb.subject = subject
return mb
}
func (mb *MessageBuilder) SetTo(name, to string) *MessageBuilder {
mb.to = mail.Address{
Name: name,
Address: to,
}
return mb
}
func (mb *MessageBuilder) SetFrom(name, from string) *MessageBuilder {
mb.from = mail.Address{
Name: name,
Address: from,
}
return mb
}
func (mb *MessageBuilder) SetBody(body string) *MessageBuilder {
mb.body = body
return mb
}