Skip to content

Instantly share code, notes, and snippets.

@MarkDBlackwell
Created December 10, 2013 20:13
Show Gist options
  • Save MarkDBlackwell/7897447 to your computer and use it in GitHub Desktop.
Save MarkDBlackwell/7897447 to your computer and use it in GitHub Desktop.
Mail::AttachmentsList#[]= with hash clobbers hash
require 'base64'
require 'mail'
mail = Mail.new
mail.text_part = Mail::Part.new{body 'body'}
mail.html_part = Mail::Part.new do
body '<html>body</html>'
content_type 'text/html; charset=UTF-8'
end
mail[:from] = 'from@from'
mail[:subject] = 'subject'
mail[:to] = 'to@to'
h = {
content: (::Base64.encode64 'some string'),
mime_type: 'application/pdf',
transfer_encoding: :base64,
}
key = 'abc'
mail.attachments[key] = h
puts h #=> {}
puts mail.attachments[key].decoded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment