r38y

r38y = r&y = randy

More Email Resources

In response to my post about ActionMailer Balancer, Chris Nagele pointed me to a blog post of his explaining the ins and outs of setting up an email system. It’s a great read so make sure you check it out.

Also check out the series of articles from Slicehost on how to set up an email server properly. 

Comments

ActionMailer Balancer

Making sure email gets delivered can be one of the more challenging aspects of developing a web application. One way to alleviate this is to use a trusted email server like Google’s. However, Google only allows users to send to 500 recipients/day with their free accounts and 2000 recipients/day with their paying accounts.   This works ok for small volumes but the limits become an issue with a medium to large applications. 

To get around this problem, Tony joked about creating a load balancer for ActionMailer. I thought it was a great idea so I created it! I would like to introduce ActionMailer Balancer. It allows you to configure several SMTP user accounts that will be used at random every time an email is created or delivered. 

To use it, configure your smtp server as usual in environment.rb:

config.action_mailer.smtp_settings = {
  :address => "smtp.gmail.com",
  :port => "587",
  :domain => "test.com",
  :authentication => :plain,
  :user_name => "no-reply1@test.com",
  :password => "password"
}

It is probably a good idea to have a default account set up. Then add something like the following to an initializer:

ActionMailer::Base.smtp_users = [
  { 
    :user_name => "no-reply1@test.com",
    :password => "password"
  },
  { 
    :user_name => "no-reply2@test.com",
    :password => "password"
  }
]

Check out the source at GitHub.

Update: If you plan to use Gmail or Google Apps to send those emails, make sure you use something like action_mailer_optional_tls until you’re using Ruby 1.9

Comments

S3 Awesomeness

We recently needed an easy way to do a few tasks with some files in Amazon’s S3. We couldn’t find anything that fit our needs out of the box so we created a thin wrapper for s3sync called S3 Awesomeness

You simply configure your production, staging, and archive buckets as well as the credentials in a yaml config file and use the available rake tasks to sync from production to staging or archive production in a separate S3 bucket. Use rake -T to see what rake tasks are available. For example, we use the following command to sync the production bucket to the staging bucket:

rake sync_from_production_to_staging

Which syncs the files locally to cache then back up to the production bucket.

You can find it at GitHub. There isn’t a license yet… I’ll get to it.

Comments

utf8 + MySQL

If you are having problems with utf8 characters in MySQL, add this to your my.conf:

[mysqld]
init_connect='SET collation_connection = utf8_general_ci'
init_connect='SET NAMES utf8'
default-character-set=utf8
character-set-server=utf8
collation-server=utf8_general_ci

Note that init_connect won’t run when the user has super privileges, so make sure you use a user without them:

REVOKE SUPER ON *.* from 'user';

if the user already has SUPER privileges.

Comments
If I’d asked people what they wanted, they would have said a faster horse. Henry Ford
Comments
Everything should be made as simple as possible — but no simpler! Albert Einstein
Comments
When once you have tasted flight, you will forever walk the earth with your eyes turned skyward, for there you have been and there you will always long to return. Leonardo da Vinci
Comments
Fork me on GitHub