Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
35 lines (27 sloc) 962 Bytes
require 'net/smtp'
class Emailer
attr_accessor :smtp_server, :domain, :account_address, :account_password, :port
def initialize(smtp_server, domain, account_address, account_password, port = 587)
self.smtp_server = smtp_server
self.domain = domain
self.account_address = account_address
self.account_password = account_password
self.port = port
end
def send(email)
email.from_address = account_address
if REALLY_SENDING
print "Mailing #{email.to_address}..."
smtp = Net::SMTP.new(smtp_server, port)
smtp.enable_starttls
smtp.start(domain, account_address, account_password, :login) do |smtp|
smtp.send_message(email.message, email.from_address, email.to_address)
end
print "sent!\n"
else
puts "**Testing; not really mailing anything**\nEmail would be as follows:\n\n"
puts email.message
puts "======"
end
end
end
Something went wrong with that request. Please try again.