ar_mailer 1.5.0

Eric Hodel | Fri, 16 Oct 2009 00:02:05 GMT

ar_mailer is a two-phase delivery agent for ActionMailer. Even delivering email to the local machine may take too long when you have to send hundreds of messages. ar_mailer allows you to store messages into the database for later delivery by a separate process, ar_sendmail.

Changes

  • Added --pid-file option. See --help for details.
  • Minor improvements to --help, argument error output

Posted in , ,  | 2 comments

multipart emails with multipart layouts and inline images in ActionMailer

Eric Hodel | Wed, 30 Sep 2009 20:14:44 GMT

While ActionMailer claims to support multipart emails, that support is severely limited.

If you have a multipart/alternative email and are using layouts, multipart layouts don't work, the text/html layout will be used for the text/plain alternative part.

You also can't embed an image to use via <img src="cid:blah"> (or CSS, etc.) in the text/html section of your multipart/alternative mail. (I want the image to be controlled via the img element and styles, not plopped into the middle of my HTML section.)

While this ticket was closed due to lack of a test, the fix involves the modification of a constant which wouldn't be tested anyhow. (It seems nobody bothered to inform TMail about this problem either.)

Enough griping!

I managed to find a solution to these two problems!

To take care of the first problem I overrode initialize_template_class in my mailer class and manually set the template format for the part:

  def initialize_template_class(assigns)
    template_format = assigns.delete :template_format

    template = super

    template.template_format = template_format if template_format

    template
  end

Then wrote a render_multipart method that manually chooses the template and layout to render:

  def render_multipart(template, options)
    content_type 'multipart/alternative'

    part :content_type => 'multipart/related' do |related|
      html_options = { :template_format => :html }.merge options

      related.part :content_type => 'text/html',
                   :body => render(:file => "#{template}.text.html.haml",
                                   :layout => 'notifier_mailer.text.html',
                                   :body => html_options)

      related.part(:content_type => 'image/png',
                   :headers => { 'Content-Id' => 'site_logo.png' }) do |image|
        image.body = File.read LOGO_PATH
        image.transfer_encoding = 'base64'
        image.content_disposition = nil
      end

    end

    plain_options = { :template_format => :plain }.merge options

    part :content_type => 'text/plain',
         :body => render(:file => "#{template}.text.plain.erb",
                         :layout => 'notifier_mailer.text.plain',
                         :body => plain_options)
  end

For Apple mail to properly display a multipart/alternative mail the top-level MIME type needs to be multipart/alternative. The text/html alternative part is wrapped inside a multipart/related part that also contains the embedded image. (When viewing the mail as text/plain the image attachment doesn't appear on the attachments bar. When viewing as text/html it does, but I don't think that there's a way to hide it from the attachments bar.)

Fixing this For Good™ seems to involve teaching ActionPack's views about how to read MIME extensions (reset.text.plain.erb and reset.text.html.erb) instead of filetype extensions (show.html.erb and show.xml.erb) like what is used by ActionController's views. The ticket seems to indicate somebody's trying to figure out how to do that.

To take care of the embedding of an image in an email for use in the HTML part I removed the restriction on Content-Id for a part header from the patch to TMail:

TMail::HeaderField::FNAME_TO_CLASS.delete 'content-id'

Then set the Content-Id for the image and unset the Content-Disposition (copied from multipart_render above):

related.part(:content_type => 'image/png',
             :headers => { 'Content-Id' => 'site_logo.png' }) do |image|
  image.body = File.read LOGO_PATH
  image.transfer_encoding = 'base64'
  image.content_disposition = nil
end

Leaving the Content-Disposition as inline causes the image to show up once at the bottom of the HTML content and once where the <img> is present.

From a mailer method this is called with the explicit template name (I was too lazy to intuit from caller):

  def reset(user, password)
    recipients user.email
    from       REPLY_TO
    subject    "Password reset"

    render_multipart 'reset', :password => password, :recipient => user
  end

In app/views/layouts/notifier_mailer.text.html.haml I have the following snippet to use the site logo:

%img.logo{ :src => 'cid:site_logo.png' }

Posted in  | no comments

ar_mailer 1.4.0

Eric Hodel | Wed, 24 Jun 2009 22:53:06 GMT

ar_mailer is a two-phase delivery agent for ActionMailer. Even delivering email to the local machine may take too long when you have to send hundreds of messages. ar_mailer allows you to store messages into the database for later delivery by a separate process, ar_sendmail.

Changes:

  • 1.8.7 and 1.9 STARTTLS compatibility, now uses smtp_tls gem for STARTTLS on 1.8.6
  • Fix 1.9 warnings

Posted in ,  | 6 comments

production_log_analyzer 1.5.1

Eric Hodel | Wed, 24 Jun 2009 03:44:37 GMT

production_log_analyzer version 1.5.1 has been released!

  • <a href=”http://seattlerb.rubyforge.org/production_log_analyzer”>Documentation
  • <a href=”http://rubyforge.org/projects/seattlerb”>Project page
  • <a href=”http://rubyforge.org/tracker/?func=add&group_id=1513&atid=5921”>Bug reports

production_log_analyzer lets you find out which actions on a Rails site are slowing you down.

Changes:

  • 1.9 and 1.8.7 compatibility.

Posted in ,  | no comments

ar_mailer 1.3.2

Eric Hodel | Wed, 29 Apr 2009 21:04:00 GMT

ar_mailer is a two-phase delivery agent for ActionMailer. Even delivering email to the local machine may take too long when you have to send hundreds of messages. ar_mailer allows you to store messages into the database for later delivery by a separate process, ar_sendmail.

Changes:

  • Terminate SMTP connection on TimeoutError since Net::SMTP may be in a bogus state. Issue by Eric O’Connell.
  • Don’t require Email class to exist. Bug #22843 by Joachim Glauche.
  • Switched to minitest
  • Upgraded to modern Hoe
  • Updated configuration information for Rails > 2.0

Posted in ,  | no comments

Sphincter version 1.1.0 has been released!

Eric Hodel | Tue, 14 Aug 2007 03:10:51 GMT

Sphincter uses Dmytro Shteflyuk’s sphinx Ruby API and automatic configuration to make totally rad ActiveRecord searching. Well, you still have to tell Sphincter what models you want to search. It doesn’t read your mind.

When updating to 1.1.0, run: rake sphincter:setup_sphinx

Changes in 1.1.0:

  • 2 major enhancements:
    • Fields across relationships may be included via add_index.
    • Sphincter now automatically configures Dmytro Shteflyuk’s sphinx API. Run `rake sphincter:setup_sphinx` and check in vendor/plugins/sphinx.
  • 1 bug fix:
    • `rake sphincter:index` task didn’t correctly run reindex. Bug submitted by Lee O’Mara.

http://seattlerb.org/Sphincter

Posted in ,  | 2 comments

ar_mailer version 1.3.1 has been released!

Eric Hodel | Wed, 01 Aug 2007 04:52:18 GMT

Even delivering email to the local machine may take too long when you have to send hundreds of messages. ar_mailer allows you to store messages into the database for later delivery by a separate process, ar_sendmail.

Changes:

  1. 1.3.1
  • Fix bug #12530, gmail causes SSL errors. Submitted by Kyle Maxwell and Alex Ostleitner.
  • Try ActionMailer::Base::server_settings then ::smtp_settings. Fixes bug #12516. Submitted by Alex Ostleitner.

http://seattlerb.org/ar_mailer

Posted in ,  | no comments

Sphincter version 1.0.0 has been released!

Eric Hodel | Mon, 30 Jul 2007 22:12:18 GMT

http://seattlerb.org/Sphincter

Sphincter uses Dmytro Shteflyuk’s sphinx Ruby API and automatic configuration to make totally rad ActiveRecord searching. Well, you still have to tell Sphincter what models you want to search. It doesn’t read your mind.

Features:

  • Automatically configures itself.
  • Handy set of rake tasks for easy, automatic management.
  • Automatically adds has_many metadata for searching across the association.
  • Stub for testing without connecting to searchd, Sphincter::SearchStub.
  • Easy pagination support.
  • Filtering by index metadata and ranges, including dates.

Problems:

  • Setting match mode not supported.
  • Setting sort mode not supported.
  • Setting per-field weights not supported.
  • Setting id range not supported.
  • Setting group-by not supported.

    See README.txt for quick-start, examples, etc.

    Changes:

    1.0.0 / 2007-07-26

    • 1 major enhancement
      • Birthday!

    http://seattlerb.org/Sphincter

    Posted in , ,  | 2 comments

  • Tim Lucas on Logging Rails to SysLog with SyslogLogger

    Eric Hodel | Wed, 06 Jun 2007 21:09:02 GMT

    Tim on switching to SyslogLogger and Production Log Analyzer:

    One of the benefits of switching your Rails app to use SysLog is taking advantage of your OS’s system-wide logging, as well as having finer grained control over how to process your log messages. For example, you can split the logs up based on Rails app, mongrel process, or even by app server if you’re using remote syslog.

    [...]

    ...and now we’re using SysLog we can use Eric’s other tool, ProductionLogAnalyzer, to identify performance bottleknecks of our application. Geoffrey Grosenbach (aka topfunky) wrote a Hodel3000CompliantLogger if you want to use this tool without SysLog).

    Logging Rails to SysLog with SyslogLogger via tech on toolmantim.com

    Posted in ,  | no comments

    ar_mailer version 1.2.0 has been released!

    Eric Hodel | Tue, 05 Jun 2007 22:28:52 GMT

    Even delivering email to the local machine may take too long when you have to send hundreds of messages. ar_mailer allows you to store messages into the database for later delivery by a separate process, ar_sendmail.

    sudo gem install ar_mailer

    Changes:

    1.2.0

    • Bugs fixed
      • Handle SMTPServerBusy by backing off @delay seconds then re-queueing
      • Allow email delivery class to be set in ARMailer.
      • ar_sendmail—mailq works with—table-name now.
    • Miscellaneous Updates
    • Added documentation to require ‘action_mailer/ar_mailer’ in instructions.
    • Moved to ZSS p4 repository
    • Supports TLS now. Requested by Dave Thomas. smtp_tls.rb from Kyle Maxwell & etc.

    http://seattlerb.org/ar_mailer

    Posted in , ,  | 2 comments

    Older posts: 1 2 3 4