module Helper class Mail attr_accessor :smtp_host, :smtp_port def initialize smtp_host ||= 'localhost' smtp_port ||= 25 end # Sends an email via smtp. # # Parameters: # * +options+ - a hash with needed configuration options for the email # * +:from+ - the senders address # * +:to+ - the recipiants address # * +:subject+ - the email subject # * +:body+ - the actual text to send in the mail def sendmail(options={}) begin Pony.mail( \ :from => options[:from], :to => options[:to], :via => :smtp, :via_options => { :address => smtp_host, :port => smtp_port, :authentication => nil, :enable_starttls_auto => false }, :subject => options[:subject], :body => options[:body] ) rescue Exception => e $log.writer.error "Can not send mail via host #{smtp_host}" $log.writer.error e.message end end end end