Skip to content

Instantly share code, notes, and snippets.

@walidvb
Created March 25, 2014 17:21
Show Gist options
  • Select an option

  • Save walidvb/9766734 to your computer and use it in GitHub Desktop.

Select an option

Save walidvb/9766734 to your computer and use it in GitHub Desktop.
def mail_subscribers(book, attrs = {})
@book = book
@body ||=attrs[:body]
if attrs[:attachments]
puts attrs[:attachments]
attrs[:attachments].all? {
|attachment|
attachments[attachment[:filename]] = attachment[:content]
}
end
mail(bcc: users.join(','), subject: attrs[:subject])
end
def self.deliver_mail_chapter(book, chapter_index, attrs = {})
attachments = Array.new
attachments.push({
:filename => "myAttachment.txt",
:content => "some content"
})
default_attrs = {
:subject => "convert",
:attachments => attachments
}
attrs = default_attrs.merge(attrs)
mail_subscribers(book, attrs).deliver
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment