diff --git a/config/config.go b/config/config.go index 2db5edf22..65bea79ba 100644 --- a/config/config.go +++ b/config/config.go @@ -140,6 +140,10 @@ type CGRConfig struct { HistoryListen string // History server listening interface: HistoryDir string // Location on disk where to store history files. HistorySaveInterval time.Duration // The timout duration between history writes + MailerServer string // The server to use when sending emails out + MailerAuthUser string // Authenticate to email server using this user + MailerAuthPass string // Authenticate to email server with this password + MailerFromAddr string // From address used when sending emails out } func (self *CGRConfig) setDefaults() error { @@ -230,6 +234,10 @@ func (self *CGRConfig) setDefaults() error { self.HistoryListen = "127.0.0.1:2013" self.HistoryDir = "/var/log/cgrates/history" self.HistorySaveInterval = time.Duration(1) * time.Second + self.MailerServer = "localhost" + self.MailerAuthUser = "cgrates" + self.MailerAuthPass = "CGRateS.org" + self.MailerFromAddr = "cgr-mailer@localhost.localdomain" return nil } @@ -557,5 +565,17 @@ func loadConfig(c *conf.ConfigFile) (*CGRConfig, error) { return nil, errParse } } + if hasOpt = c.HasOption("mailer", "server"); hasOpt { + cfg.MailerServer, _ = c.GetString("mailer", "server") + } + if hasOpt = c.HasOption("mailer", "auth_user"); hasOpt { + cfg.MailerAuthUser, _ = c.GetString("mailer", "auth_user") + } + if hasOpt = c.HasOption("mailer", "auth_passwd"); hasOpt { + cfg.MailerAuthPass, _ = c.GetString("mailer", "auth_passwd") + } + if hasOpt = c.HasOption("mailer", "from_address"); hasOpt { + cfg.MailerFromAddr, _ = c.GetString("mailer", "from_address") + } return cfg, nil } diff --git a/config/config_test.go b/config/config_test.go index 0e43924d8..97193d9ad 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -133,6 +133,10 @@ func TestDefaults(t *testing.T) { eCfg.HistoryListen = "127.0.0.1:2013" eCfg.HistoryDir = "/var/log/cgrates/history" eCfg.HistorySaveInterval = time.Duration(1)*time.Second + eCfg.MailerServer = "localhost" + eCfg.MailerAuthUser = "cgrates" + eCfg.MailerAuthPass = "CGRateS.org" + eCfg.MailerFromAddr = "cgr-mailer@localhost.localdomain" if !reflect.DeepEqual(cfg, eCfg) { t.Log(eCfg) t.Log(cfg) @@ -256,6 +260,10 @@ func TestConfigFromFile(t *testing.T) { eCfg.HistoryListen = "test" eCfg.HistoryDir = "test" eCfg.HistorySaveInterval = time.Duration(99)*time.Second + eCfg.MailerServer = "test" + eCfg.MailerAuthUser = "test" + eCfg.MailerAuthPass = "test" + eCfg.MailerFromAddr = "test" if !reflect.DeepEqual(cfg, eCfg) { t.Log(eCfg) t.Log(cfg) diff --git a/config/test_data.txt b/config/test_data.txt index 0b820a81c..5d1990ea3 100644 --- a/config/test_data.txt +++ b/config/test_data.txt @@ -113,3 +113,8 @@ save_interval = 99 # Timeout duration between saves enabled = true # Starts History as a client: . server = test # Address where to reach the master history server: +[mailer] +server = test # The server to use when sending emails out +auth_user = test # Authenticate to email server using this user +auth_passwd = test # Authenticate to email server with this password +from_address = test # From address used when sending emails out diff --git a/data/conf/cgrates.cfg b/data/conf/cgrates.cfg index 1ba1e1a2c..b310545d0 100644 --- a/data/conf/cgrates.cfg +++ b/data/conf/cgrates.cfg @@ -115,3 +115,9 @@ # enabled = false # Starts History as a client: . # server = 127.0.0.1:2013 # Address where to reach the master history server: +[mailer] +# server = localhost # The server to use when sending emails out +# auth_user = cgrates # Authenticate to email server using this user +# auth_passwd = CGRateS.org # Authenticate to email server with this password +# from_address = cgr-mailer@localhost.localdomain # From address used when sending emails out +