mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
parent
dcfd8d8fe8
commit
46572b871f
5 changed files with 43 additions and 11 deletions
|
|
@ -15,7 +15,7 @@ import (
|
|||
|
||||
var (
|
||||
ErrBlacklistedAddress = errors.New("Email address is blacklisted")
|
||||
ErrInvalidAddress = errors.New("Email address is blacklisted")
|
||||
ErrInvalidAddress = errors.New("Email address is invalid")
|
||||
ErrNoMXRecord = errors.New("Couldn't resolve MX record")
|
||||
)
|
||||
|
||||
|
|
@ -73,6 +73,11 @@ func (config *MailtoConfig) Postprocess(heloDomain string) (err error) {
|
|||
return config.DKIM.Postprocess()
|
||||
}
|
||||
|
||||
// are we sending email directly, as opposed to deferring to an MTA?
|
||||
func (config *MailtoConfig) DirectSendingEnabled() bool {
|
||||
return config.MTAReal.Server == ""
|
||||
}
|
||||
|
||||
// get the preferred MX record hostname, "" on error
|
||||
func lookupMX(domain string) (server string) {
|
||||
var minPref uint16
|
||||
|
|
@ -104,7 +109,7 @@ func SendMail(config MailtoConfig, recipient string, msg []byte) (err error) {
|
|||
|
||||
var addr string
|
||||
var auth smtp.Auth
|
||||
if config.MTAReal.Server != "" {
|
||||
if !config.DirectSendingEnabled() {
|
||||
addr = fmt.Sprintf("%s:%d", config.MTAReal.Server, config.MTAReal.Port)
|
||||
if config.MTAReal.Username != "" && config.MTAReal.Password != "" {
|
||||
auth = smtp.PlainAuth("", config.MTAReal.Username, config.MTAReal.Password, config.MTAReal.Server)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue