up
This commit is contained in:
@@ -16,6 +16,7 @@ type Config struct {
|
||||
User string
|
||||
Password string
|
||||
From string
|
||||
ReplyTo string // optional Reply-To: where replies should go (e.g. a personal inbox)
|
||||
Encryption string // "ssl" | "starttls" | "none"
|
||||
Auth bool // SMTP requires authorization (send username/password)
|
||||
}
|
||||
@@ -57,6 +58,11 @@ func Send(cfg Config, to, subject, body, attachPath string) error {
|
||||
if err := m.To(to); err != nil {
|
||||
return fmt.Errorf("bad recipient %q: %w", to, err)
|
||||
}
|
||||
if cfg.ReplyTo != "" {
|
||||
if err := m.ReplyTo(cfg.ReplyTo); err != nil {
|
||||
return fmt.Errorf("bad reply-to %q: %w", cfg.ReplyTo, err)
|
||||
}
|
||||
}
|
||||
m.Subject(subject)
|
||||
m.SetBodyString(mail.TypeTextPlain, body)
|
||||
if attachPath != "" {
|
||||
|
||||
Reference in New Issue
Block a user