diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 3d5d3cba3..ea9542041 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -85,6 +85,7 @@ information, please see the [`CONTRIBUTING.md`](CONTRIBUTING.md) file. | @nickvsnetworking | Nick Jones | | @Eda91 | Edlira Eltari | | @gezimbll | Gezim Blliku| +| @ruhnet | Ruel Tmeizeh | diff --git a/engine/action.go b/engine/action.go index 56a966871..3b5ded3dc 100644 --- a/engine/action.go +++ b/engine/action.go @@ -402,7 +402,10 @@ func mailAsync(ub *Account, a *Action, acs Actions, _ *FilterS, extraData interf } message = []byte(fmt.Sprintf("To: %s\r\nSubject: [CGR Notification] Threshold hit on Balance: %s\r\n\r\nTime: \r\n\t%s\r\n\r\nBalance:\r\n\t%s\r\n\r\nYours faithfully,\r\nCGR Balance Monitor\r\n", toAddrStr, ub.ID, time.Now(), balJsn)) } - auth := smtp.PlainAuth("", cgrCfg.MailerCfg().MailerAuthUser, cgrCfg.MailerCfg().MailerAuthPass, strings.Split(cgrCfg.MailerCfg().MailerServer, ":")[0]) // We only need host part, so ignore port + var auth smtp.Auth + if len(cgrCfg.MailerCfg().MailerAuthUser) > 0 || len(cgrCfg.MailerCfg().MailerAuthPass) > 0 { //use auth if user/pass not empty in config + auth = smtp.PlainAuth("", cgrCfg.MailerCfg().MailerAuthUser, cgrCfg.MailerCfg().MailerAuthPass, strings.Split(cgrCfg.MailerCfg().MailerServer, ":")[0]) // We only need host part, so ignore port + } go func() { for i := 0; i < 5; i++ { // Loop so we can increase the success rate on best effort if err := smtp.SendMail(cgrCfg.MailerCfg().MailerServer, auth, cgrCfg.MailerCfg().MailerFromAddr, toAddrs, message); err == nil {