<commit_before>= postmark-rails gem

The Postmark Rails Gem is a drop-in plug-in for ActionMailer to send emails via Postmark, an email delivery service for web apps. The gem has been created for fast implementation and fully supports all of Postmark’s features.

== Supported Rails Versions

* lower than 2.3: could work, but not tested
* 2.3 and higher
* 3.0

== Install

    sudo gem install postmark-rails

== Requirements

* "postmark" gem version 0.8 and higher is required.
* You will also need a Postmark account, server and sender signature set up to use it. To get an account, sign up at http://postmarkapp.com.

== Configuring your Rails application

=== Rails 3

Add this to your Gemfile: (change version numbers if needed)

    gem 'postmark-rails', '0.4.1'
    
Don't forget to run "bundle install" command every time you change something in the Gemfile.

Add this to your config/application.rb:

    config.action_mailer.delivery_method   = :postmark
    config.action_mailer.postmark_settings = { :api_key => "your-api-key" }
    
=== Rails 2

Add this to config/environment.rb:

    Rails::Initializer.run do |config|
    
      ...
    
      config.gem 'postmark-rails'
      require    'postmark-rails'
      
      config.action_mailer.postmark_api_key = "your-api-key"
      config.action_mailer.delivery_method  = :postmark
      
      ...
      
    end

For API details, refer to the developer documentation at http://developer.postmarkapp.com.

== Tagging your deliveries

You can use a tag to categorize outgoing messages and attach application-specific information. Tagging the different types of email that you send lets you review statistics and bounce reports separately. Read more at http://developer.postmarkapp.com/developer-build.html#message-format.

=== Rails 3

    class TestMailer < ActionMailer::Base
    
      def tagged_message
        mail(
          :subject => 'hello',
          :to      => '<EMAIL>',
          :from    => '<EMAIL>',
          :tag     => 'my-tag'
        )
      end
      
    end
      
=== Rails 2

    class SuperMailer < ActionMailer::Base
    
      def email
        from       "<EMAIL>"
        subject    "Some marvelous email message"
        recipients "<EMAIL>"
        tag        "my-another-tag"
      end
    
    end

== Sending attachments

You can also send file attachments with Postmark. Read more here: http://developer.postmarkapp.com/developer-build.html#attachments

=== Rails 3

    class TestMailer < ActionMailer::Base
    
      def message_with_attachment
        mail(
          :subject              => 'hello',
          :to                   => '<EMAIL>',
          :from                 => '<EMAIL>',
          :postmark_attachments => [File.open("/path/to/file")]
        )
      end
      
    end

=== Rails 2

    class SuperMailer < ActionMailer::Base
    
      def email
        from                 "<EMAIL>"
        subject              "Some marvelous email message"
        recipients           "<EMAIL>"
        postmark_attachments [File.open("/path/to/file")]
      end
    
    end
    
You can pass either an array of File objects or a single object. Postmark will detect the file name automatically and send an attachment with the "application/octet-stream" content type. If you want more control on how attachments get formatted, you can pass Hash objects, which contain the custom settings such as file name or content-type. Here is an example:

    #
    # Don't forget to read your file and base64-encode it,
    # before assigning it to "Content".
    #
    message.postmark_attachments = {
      "Name"        => "fancy-file-name.jpg",
      "Content"     => [ IO.read("path/to/file") ].pack("m"),
      "ContentType" => "image/jpeg"<commit_msg>Update README.rdoc<commit_after>= postmark-rails gem

The Postmark Rails Gem is a drop-in plug-in for ActionMailer to send emails via Postmark, an email delivery service for web apps. The gem has been created for fast implementation and fully supports all of Postmark’s features.

== Supported Rails Versions

* lower than 2.3: could work, but not tested
* 2.3 and higher
* 3.0

== Install

    sudo gem install postmark-rails

== Requirements

* "postmark" gem version 0.8 and higher is required.
* You will also need a Postmark account, server and sender signature set up to use it. To get an account, sign up at http://postmarkapp.com.

== Configuring your Rails application

=== Rails 3

Add this to your Gemfile: (change version numbers if needed)

    gem 'postmark-rails', '0.4.1'
    
Don't forget to run "bundle install" command every time you change something in the Gemfile.

Add this to your config/application.rb:

    config.action_mailer.delivery_method   = :postmark
    config.action_mailer.postmark_settings = { :api_key => "your-api-key" }
    
=== Rails 2

Add this to config/environment.rb:

    Rails::Initializer.run do |config|
    
      ...
    
      config.gem 'postmark-rails'
      require    'postmark-rails'
      
      config.action_mailer.postmark_api_key = "your-api-key"
      config.action_mailer.delivery_method  = :postmark
      
      ...
      
    end

For API details, refer to the developer documentation at http://developer.postmarkapp.com.

== Tagging your deliveries

You can use a tag to categorize outgoing messages and attach application-specific information. Tagging the different types of email that you send lets you review statistics and bounce reports separately. Read more at http://developer.postmarkapp.com/developer-build.html#message-format.

=== Rails 3

    class TestMailer < ActionMailer::Base
    
      def tagged_message
        mail(
          :subject => 'hello',
          :to      => '<EMAIL>',
          :from    => '<EMAIL>',
          :tag     => 'my-tag'
        )
      end
      
    end
      
=== Rails 2

    class SuperMailer < ActionMailer::Base
    
      def email
        from       "<EMAIL>"
        subject    "Some marvelous email message"
        recipients "<EMAIL>"
        tag        "my-another-tag"
      end
    
    end

== Sending attachments

You can also send file attachments with Postmark. Read our Developer docs for additional information: http://developer.postmarkapp.com/developer-build.html#attachments.

The Postmark gem is compatible with [ActionMailer attachments API](http://api.rubyonrails.org/classes/ActionMailer/Base.html#method-i-attachments).

The legacy #postmark_attachments method is no longer supported on Rails 3.2.13 and above.

=== Rails 3

    class TestMailer < ActionMailer::Base
    
      def message_with_attachment
        attachment['42.jpg'] = File.read("/path/to/file")
        mail(
          :subject              => 'hello',
          :to                   => '<EMAIL>',
          :from                 => '<EMAIL>'
        )
      end
      
    end

=== Rails 2

    class SuperMailer < ActionMailer::Base
    
      def email
        from                 "<EMAIL>"
        subject              "Some marvelous email message"
        recipients           "<EMAIL>"
        postmark_attachments [File.open("/path/to/file")]
      end
    
    end
    
You can pass either an array of File objects or a single object. Postmark will detect the file name automatically and send an attachment with the "application/octet-stream" content type. If you want more control on how attachments get formatted, you can pass Hash objects, which contain the custom settings such as file name or content-type. Here is an example:

    #
    # Don't forget to read your file and base64-encode it,
    # before assigning it to "Content".
    #
    message.postmark_attachments = {
      "Name"        => "fancy-file-name.jpg",
      "Content"     => [ IO.read("path/to/file") ].pack("m"),
      "ContentType" => "image/jpeg"
{'fraction_non_alphanumeric': 0.08867562380038388, 'fraction_numerical': 0.005630198336532309, 'mean_word_length': 2.387949718248808, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1615840', 'n_tokens_mistral': 2261, 'n_tokens_neox': 2154, 'n_words': 772}