Search posterous

Search all posts and users. Type a name, type a favorite song title, whatever! See what comes up.
  

More posterous blogs











More recommended blogs »

Here are posterous posts filed under actionmailer...

dchua says...

I'm thinking of implementing something like how ActionMailer does their dynamic deliver_* methods for this opensource rails messaging plugin I'm currently working on, but I'm not sure how should I go around working it.

I'm thinking of doing an easy-to-configure HTML templating system that would allow users to customize the output of commonly sent out messages.

But what do you think? Is it even necessary? Or am I adding code bloat.

Filed under: actionmailer

rosscoops says...

Following on from the previous post on how to send an email, here's how to add an attachment to our hello_email method:

def hello_email
  ...as before...
  attachment(:content_type => "application/zip",
    :filename => "foo.zip",
    :body => File.read("foo.zip"))
end

Filed under: actionmailer

rosscoops says...

ActionMailer can be used from Ruby as well as from Rails. Heres an example class...

class Postman
  def hello_email
    recipients "you@foo.com"
    from "me@foo.com"
    subject "Hello"
    body "Hello you..."
  end  
end

...and how to call it - Postman.deliver_hello_email - yep that's right, ActionMailer prefixes your function name with deliver_

Filed under: actionmailer

rosscoops says...

Want to use ActionMailer to send emails from your DreamHost email account? Here's what you need to do to set it up...

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
  :address => "mail.foo.com", :domain => "foo.com",
  :port => 587, :authentication => :login,
  :user_name => "me", :password => "secret"
}
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.default_charset = "utf-8"

Obviously you need to replace foo, me & secret with your domain and login info!

Filed under: actionmailer

rosscoops says...

Today I was using ActionMailer (more on that later) when I noticed that it was messing with the formatting of my log files produced through Logger. Basically it was removing all of the DateTime prefix stuff that Logger usually generates, which I happened to need:

Normal logger output: I, [14:59:00#1348]  INFO -- : foo
Logger output after requiring ActionMailer: foo

After a bit of investigating, it turns out that ActionMailer is using ActiveSupport/clean_logger to change Logger's format_message call. Luckily for us you can change it back really easily, just add the following code to your app:

class Logger
  alias format_message old_format_message
end

Basically clean_logger aliases the original Logger.format_message to old_format_message, so my class just aliases is back again :-)

Filed under: actionmailer