Class: Email
- Inherits:
-
Object
- Object
- Defined in:
- lib/sysdog/email.rb
Instance Attribute Summary collapse
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
-
#initialize ⇒ Email
constructor
A new instance of Email.
- #send(title, content) ⇒ Object
Constructor Details
#initialize ⇒ Email
Returns a new instance of Email.
6 7 8 |
# File 'lib/sysdog/email.rb', line 6 def initialize @email = YAML.load_file(File.dirname(__FILE__) + "/../config.yml") end |
Instance Attribute Details
#to ⇒ Object
Returns the value of attribute to.
5 6 7 |
# File 'lib/sysdog/email.rb', line 5 def to @to end |
Instance Method Details
#send(title, content) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sysdog/email.rb', line 9 def send(title,content) = <<EndOfMail From: #{Sysdog.name} #{Sysdog::VERSION} <#{@email['email']['address']}> To: <#{@to}> Subject: #{title} Date: #{Time.new} Content-type: text/html <html><body>#{content}\n\r\t\t\tPower By #{Sysdog.name} #{Sysdog::VERSION}</body></html> EndOfMail Net::SMTP.start( @email['email']['server'], @email['email']['port'].to_s, @email['email']['server_alias'], @email['email']['address'], @email['email']['password'].to_s, @email['email']['auth_type'].to_sym) {|smtp| smtp.send_mail , @email['email']['address'], @to } end |