@@ -43,6 +43,7 @@ type (
|
||||
Timeout time.Duration
|
||||
User string
|
||||
Password string
|
||||
TLSRequired bool
|
||||
}
|
||||
)
|
||||
|
||||
@@ -90,6 +91,12 @@ func (m *Mailer) sendMailWithTimeout(ctx context.Context, to []string, msg []byt
|
||||
}
|
||||
defer c.Quit()
|
||||
|
||||
if m.cfg.TLSRequired {
|
||||
if err := c.StartTLS(nil); err != nil {
|
||||
return fmt.Errorf("TLS negotiation error: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if m.cfg.User != "" && m.cfg.Password != "" {
|
||||
auth := smtp.PlainAuth("", m.cfg.User, m.cfg.Password, host)
|
||||
if err = c.Auth(auth); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user