[#3097] added SmtpConfig.LocalName option

This commit is contained in:
Gani Georgiev
2023-08-17 19:07:56 +03:00
parent 53b20ec104
commit b2ac538580
38 changed files with 3461 additions and 3363 deletions
+19 -6
View File
@@ -39,12 +39,21 @@ func NewSmtpClient(
// SmtpClient defines a SMTP mail client structure that implements
// `mailer.Mailer` interface.
type SmtpClient struct {
Host string
Port int
Username string
Password string
Tls bool
AuthMethod string // default to "PLAIN"
Host string
Port int
Username string
Password string
Tls bool
// SMTP auth method to use
// (if not explicitly set, defaults to "PLAIN")
AuthMethod string
// LocalName is optional domain name used for the EHLO/HELO exchange
// (if not explicitly set, defaults to "localhost").
//
// This is required only by some SMTP servers, such as Gmail SMTP-relay.
LocalName string
}
// Send implements `mailer.Mailer` interface.
@@ -71,6 +80,10 @@ func (c *SmtpClient) Send(m *Message) error {
yak = mailyak.New(fmt.Sprintf("%s:%d", c.Host, c.Port), smtpAuth)
}
if c.LocalName != "" {
yak.LocalName(c.LocalName)
}
if m.From.Name != "" {
yak.FromName(m.From.Name)
}