Class: Communify::Controllers::Email

Inherits:
Object
  • Object
show all
Defined in:
lib/communify/controllers/email_controller.rb

Class Method Summary collapse

Class Method Details

.create_log(mail) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/communify/controllers/email_controller.rb', line 4

def self.create_log(mail)
    content = "Subject: #{mail.subject}, Body: #{mail.body}"
    recipient = self.comma_separated(mail.to) + self.comma_separated(mail.cc) + self.comma_separated(mail.bcc)
    resource = CommunifyLog.new(content: content, recipient: recipient, status: "Mail delivered at #{mail.date}", third_party_id: mail.message_id, content_type: 2, attempt_count: 1)
    if resource.save
        return resource.id
    else    
        raise "Error => Resource has not been saved!!"
    end
end