Method: WCC::MailNotificator.parse_conf

Defined in:
lib/wcc/mail.rb

.parse_conf(conf) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/wcc/mail.rb', line 76

def self.parse_conf(conf)
  if conf.is_a?(Hash)
    if conf['smtp'].is_a?(Hash)
      from_mail = MailAddress.new(conf['smtp']['from'] || "#{Etc.getlogin}@localhost")
      return {
        :mailer => 'smtp',
        :from_mail => from_mail,
        :smtp_host => conf['smtp']['host'] || 'localhost',
        :smtp_port => conf['smtp']['port'] || 25
      }
    elsif conf['fake_file'].is_a?(Hash)
      from_mail = MailAddress.new(conf['fake_file']['from'] || "#{Etc.getlogin}@localhost")
      return {
        :mailer => 'fake_file',
        :from_mail => from_mail
      }
    end
  end
  # default is smtp
  WCC.logger.debug "Using default SMTP configuration for MailNotificator"
  return {
    :mailer => 'smtp',
    :from_mail => MailAddress.new("#{Etc.getlogin}@localhost"),
    :smtp_host => 'localhost',
    :smtp_port => 25
  }
end