diff options
author | Mikel Lindsaar <raasdnil@gmail.com> | 2010-06-07 23:14:54 -0400 |
---|---|---|
committer | Mikel Lindsaar <raasdnil@gmail.com> | 2010-06-07 23:14:54 -0400 |
commit | 3762362eab9663b3c9bc6d4b831e402917f95e93 (patch) | |
tree | 03f08a053640b938f1654301433ebcdb543aaa74 /actionmailer/lib/action_mailer | |
parent | 311d99eef01c268cedc6e9b3bdb9abc2ba5c6bfa (diff) | |
download | rails-3762362eab9663b3c9bc6d4b831e402917f95e93.tar.gz rails-3762362eab9663b3c9bc6d4b831e402917f95e93.tar.bz2 rails-3762362eab9663b3c9bc6d4b831e402917f95e93.zip |
Updating readme for ActionMailer::Base
Diffstat (limited to 'actionmailer/lib/action_mailer')
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 9fb3ba425f..7da033b6af 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -36,6 +36,9 @@ module ActionMailer #:nodoc: # * <tt>attachments[]=</tt> - Allows you to add attachments to your email in an intuitive # manner; <tt>attachments['filename.png'] = File.read('path/to/filename.png')</tt> # + # * <tt>attachments.inline[]=</tt> - Allows you to add an inline attachment to your email + # in the same manner as <tt>attachments[]=</tt> + # # * <tt>headers[]=</tt> - Allows you to specify any header field in your email such # as <tt>headers['X-No-Spam'] = 'True'</tt>. Note, while most fields (like <tt>To:</tt> # <tt>From:</tt> can only appear once in an email header, other fields like <tt>X-Anything</tt> @@ -173,7 +176,7 @@ module ActionMailer #:nodoc: # # class ApplicationMailer < ActionMailer::Base # def welcome(recipient) - # attachments['free_book.pdf'] = { :data => File.read('path/to/file.pdf') } + # attachments['free_book.pdf'] = File.read('path/to/file.pdf') # mail(:to => recipient, :subject => "New account information") # end # end @@ -184,6 +187,34 @@ module ActionMailer #:nodoc: # and the second being a <tt>application/pdf</tt> with a Base64 encoded copy of the file.pdf book # with the filename +free_book.pdf+. # + # = Inline Attachments + # + # You can also specify that a file should be displayed inline with other HTML. For example a + # corporate logo or a photo or the like. + # + # To do this is simple, in the Mailer: + # + # class ApplicationMailer < ActionMailer::Base + # def welcome(recipient) + # attachments.inline['photo.png'] = File.read('path/to/photo.png') + # mail(:to => recipient, :subject => "Here is what we look like") + # end + # end + # + # And then to reference the image in the view, you create a <tt>welcome.html.erb</tt> file and + # make a call to +image_tag+ passing in the attachment you want to display and then call + # +url+ on the attachment to get the relative content id path for the image source: + # + # <h1>Please Don't Cringe</h1> + # + # <%= image_tag attachments['photo.png'].url -%> + # + # As we are using ActionView's +image_tag+ method, you can pass in any other options you want: + # + # <h1>Please Don't Cringe</h1> + # + # <%= image_tag attachments['photo.png'].url, :alt => 'Our Photo', :class => 'photo' -%> + # # = Observing and Intercepting Mails # # Action Mailer provides hooks into the Mail observer and interceptor methods. These allow you to |