class Torque::Mailer

Handles sending the finished release notes document to a list of emails after Torque generates it

Public Class Methods

new(email, password) click to toggle source

@param email An email address @param password A password that matches the email address given

Creates a Mailer that will send emails from the email address/password combo given

# File lib/torque/mailer.rb, line 14
def initialize(email, password)
  @email = email
  @password = password

  options = { :address              => "smtp.gmail.com",
              :port                 => 587,
              :domain               => 'gmail.com',
              :user_name            => @email,
              :password             => @password,
              :authentication       => 'plain',
              :enable_starttls_auto => true }

  Mail.defaults do
    delivery_method :smtp, options
  end
end

Public Instance Methods

send_notes(notes_string, subject_line, address_list) click to toggle source

@param notes_string The release notes file in string form @param subject_line The subject line to use in the email @param address_list A comma-separated list of email addresses to which to send the notes

Sends notes_string as an email with subject_line from an arbitrary email address to everyone on address_list

# File lib/torque/mailer.rb, line 36
def send_notes(notes_string, subject_line, address_list)

  mail = Mail::Message.new
  
  mail.charset = "UTF-8"
  mail.to        address_list
  mail.from      @email
  mail.subject   subject_line
  mail.body      notes_string
  
  begin
    mail.deliver
  rescue Net::SMTPAuthenticationError
    # TODO Remove this output. Should fail silently and be replaced by an independent call to :verify
    puts "Username and password not accepted by Gmail. Check your username and password or try using a Gmail " \
      "account"
  end

end