mirror of
https://github.com/wiggin77/mailrelay.git
synced 2025-08-09 15:24:58 +02:00
Support HELO
This commit is contained in:
13
client.go
13
client.go
@ -92,12 +92,25 @@ func sendMail(e *mail.Envelope, config *relayConfig) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handshake(client *smtp.Client, config *relayConfig, tlsConfig *tls.Config) error {
|
func handshake(client *smtp.Client, config *relayConfig, tlsConfig *tls.Config) error {
|
||||||
|
if config.HeloHost != "" {
|
||||||
|
if err := client.Hello(config.HeloHost); err != nil {
|
||||||
|
return errors.Wrap(err, "HELO error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if config.STARTTLS {
|
if config.STARTTLS {
|
||||||
if err := client.StartTLS(tlsConfig); err != nil {
|
if err := client.StartTLS(tlsConfig); err != nil {
|
||||||
return errors.Wrap(err, "starttls error")
|
return errors.Wrap(err, "starttls error")
|
||||||
}
|
}
|
||||||
|
// Re-HELO after STARTTLS
|
||||||
|
if config.HeloHost != "" {
|
||||||
|
if err := client.Hello(config.HeloHost); err != nil {
|
||||||
|
return errors.Wrap(err, "HELO error")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var auth smtp.Auth
|
var auth smtp.Auth
|
||||||
if config.LoginAuthType {
|
if config.LoginAuthType {
|
||||||
auth = LoginAuth(config.Username, config.Password)
|
auth = LoginAuth(config.Username, config.Password)
|
||||||
|
@ -64,6 +64,7 @@ type relayConfig struct {
|
|||||||
Username string `json:"smtp_username"`
|
Username string `json:"smtp_username"`
|
||||||
Password string `json:"smtp_password"`
|
Password string `json:"smtp_password"`
|
||||||
SkipVerify bool `json:"smtp_skip_cert_verify"`
|
SkipVerify bool `json:"smtp_skip_cert_verify"`
|
||||||
|
HeloHost string `json:"smtp_helo"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// mailRelayProcessor decorator relays emails to another SMTP server.
|
// mailRelayProcessor decorator relays emails to another SMTP server.
|
||||||
|
Reference in New Issue
Block a user