Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 0c1b47657c
Fetching contributors…

Cannot retrieve contributors at this time

45 lines (36 sloc) 0.942 kB
require 'snitch/service'
require 'tmail'
require 'net/smtp'
class Snitch
module Services
class Email < Service
def initialize(options)
super(options)
end
def tattle(message)
send_email(create_email(message))
end
def send_email(email)
email_opts = %W(server port host login password auth_method).collect { |attr| lookup(attr) }
Net::SMTP.start(*email_opts) do |smtp|
smtp.send_message(email.to_s, from, to)
end
end
def create_email(message)
mail = TMail::Mail.new
mail.to = to
mail.from = from
mail.subject = message[0, message.index("\n") || message.length]
mail.date = Time.now
mail.set_content_type 'text', 'plain'
mail.body = message
mail
end
def lookup(var)
self.send(var)
rescue NameError
nil
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.