Skip to content
Browse files

Resolves issue #7 - Readme and docs incorrect for Message#add_file

  • Loading branch information...
1 parent 300202f commit f0930bbade83e6f186e1dee3495805bc705827e1 @mikel committed Nov 10, 2009
Showing with 20 additions and 3 deletions.
  1. +2 −0 CHANGELOG.rdoc
  2. +2 −2 README.rdoc
  3. +16 −1 lib/mail/message.rb
View
2 CHANGELOG.rdoc
@@ -1,6 +1,8 @@
== Tue Nov 10 08:15:14 UTC 2009 Mikel Lindsaar <raasdnil@gmail.com>
* Resolved Issue #5 - Message ID generation issue
+* Resolved Issue #7 - README add_file examples don't seem to work - Updated readme and
+ rdoc in Message#add_file
== Mon Nov 9 23:38:33 UTC 2009 Mikel Lindsaar <raasdnil@gmail.com>
View
4 README.rdoc
@@ -205,7 +205,7 @@ what you are doing.
to 'you@test.lindsaar.net'
subject 'Here is the image you wanted'
body File.read('body.txt')
- add_file 'New Header Image', '/somefile.png'
+ add_file '/somefile.png'
end
or
@@ -219,7 +219,7 @@ or
to 'you@test.lindsaar.net'
subject 'Here is the image you wanted'
body File.read('body.txt')
- add_file 'New Header Image', '/somefile.png'
+ add_file {:filename => 'somefile.png', :data => File.read('/somefile.png')}
end
mail.deliver!
View
17 lib/mail/message.rb
@@ -565,7 +565,22 @@ def add_part(part)
self.body << part
end
- # Adds a file to the message.
+ # Adds a file to the message. You have two options with this method, you can
+ # just pass in the absolute path to the file you want and Mail will read the file,
+ # get the filename from the path you pass in and guess the mime type, or you
+ # can pass in the filename as a string, and pass in the file data as a blob.
+ #
+ # Example:
+ #
+ # m = Mail.new
+ # m.add_file('/path/to/filename.png')
+ #
+ # or
+ #
+ # m = Mail.new
+ # m.add_file(:filename => 'filename.png', :data => File.read('/path/to/filename.png'))
+ #
+ # The above two alternatives will produce the same email message.
def add_file(options)
add_multipart_mixed_header
if options.is_a?(Hash)

0 comments on commit f0930bb

Please sign in to comment.
Something went wrong with that request. Please try again.