Adding mailer configuration

This commit is contained in:
DanB
2014-01-22 21:06:57 +01:00
parent 08e5d8540a
commit 2c3e8e1584
4 changed files with 39 additions and 0 deletions

View File

@@ -140,6 +140,10 @@ type CGRConfig struct {
HistoryListen string // History server listening interface: <internal|x.y.z.y:1234>
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
}

View File

@@ -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)

View File

@@ -113,3 +113,8 @@ save_interval = 99 # Timeout duration between saves
enabled = true # Starts History as a client: <true|false>.
server = test # Address where to reach the master history server: <internal|x.y.z.y:1234>
[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

View File

@@ -115,3 +115,9 @@
# enabled = false # Starts History as a client: <true|false>.
# server = 127.0.0.1:2013 # Address where to reach the master history server: <internal|x.y.z.y:1234>
[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