Until I launch OS X, I really work with OS Xers, and we all use sendmailin development. All you have to do is configure it only for your development environment.
In config/environments/development.rb:
AppName::Application.configure do
config.action_mailer.delivery_method = :sendmail
config.action_mailer.sendmail_settings = {
:location => '/usr/sbin/sendmail',
:arguments => '-i -t'
}
end
Then in your email program, you can add a private method to determine who to send email to if you are worried about accidentally sending email to users / random email addresses:
class UserMailer < ActionMailer
default :from => 'from.email@example.com'
def welcome(user)
@user = user
mail(
:subject => "Hello World",
:to => recipient(@user.email)
)
end
private
def recipient(email_address)
return 'developer.email@example.com' if Rails.env.development?
email_address
end
end
source
share