Class: Reviewr::Mailer

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewr/mailer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ Mailer

Returns a new instance of Mailer.



7
8
9
# File 'lib/reviewr/mailer.rb', line 7

def initialize(project)
  @project = project
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



5
6
7
# File 'lib/reviewr/mailer.rb', line 5

def project
  @project
end

Instance Method Details

#send(body) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/reviewr/mailer.rb', line 11

def send(body)
  Pony.mail(:from => @project.user_email,
            :to   => @project.to,
            :body => body,
            :subject => "Code review request: #{@project.review_subject}",
            :via  => :smtp,
            :smtp => {
              :host     => 'smtp.gmail.com',
              :port     => '587',
              :user     => @project.user_email,
              :tls      => true,
              :password => @project.email_password,
              :auth     => :plain,
              :domain   => @project.email_server
            })
  true
rescue => e
  $stderr.puts "Error sending email:"
  $stderr.puts e.inspect
  false
end