Class: Mailboxer::MessageMailer

Inherits:
BaseMailer
  • Object
show all
Defined in:
app/mailers/mailboxer/message_mailer.rb

Instance Method Summary collapse

Instance Method Details

#new_message_email(message, receiver) ⇒ Object

Sends an email for indicating a new message for the receiver



14
15
16
17
18
19
20
21
# File 'app/mailers/mailboxer/message_mailer.rb', line 14

def new_message_email(message,receiver)
  @message  = message
  @receiver = receiver
  set_subject(message)
  mail :to => receiver.send(Mailboxer.email_method, message),
       :subject => t('mailboxer.message_mailer.subject_new', :subject => @subject),
       :template_name => 'new_message_email'
end

#reply_message_email(message, receiver) ⇒ Object

Sends and email for indicating a reply in an already created conversation



24
25
26
27
28
29
30
31
# File 'app/mailers/mailboxer/message_mailer.rb', line 24

def reply_message_email(message,receiver)
  @message  = message
  @receiver = receiver
  set_subject(message)
  mail :to => receiver.send(Mailboxer.email_method, message),
       :subject => t('mailboxer.message_mailer.subject_reply', :subject => @subject),
       :template_name => 'reply_message_email'
end

#send_email(message, receiver) ⇒ Object

Sends and email for indicating a new message or a reply to a receiver. It calls new_message_email if notifing a new message and reply_message_email when indicating a reply to an already created conversation.



5
6
7
8
9
10
11
# File 'app/mailers/mailboxer/message_mailer.rb', line 5

def send_email(message, receiver)
  if message.conversation.messages.size > 1
    reply_message_email(message,receiver)
  else
    new_message_email(message,receiver)
  end
end