SMTP Authentication for emails

2 views
Skip to first unread message

Ivan

unread,
Sep 27, 2009, 4:49:46 PM9/27/09
to Insoshi
Hey there, thank you for your help with getting this installed, now
i've run into another problem. My SMTP server requires
authentication, and I think thats why inshoshi isnt able to send any
emails out. Is there a way to include credentials into the smtp link
or some kind of work around that anyone knows of?

Dan B

unread,
Sep 28, 2009, 2:52:51 AM9/28/09
to Insoshi

Shea Sullivan

unread,
Sep 28, 2009, 12:13:35 PM9/28/09
to ins...@googlegroups.com
I got it working in Insoshi with a migration like this:

class SmtpAuthenticationPreferences < ActiveRecord::Migration
  def self.up
    add_column :preferences, :smtp_user_name, :string
    add_column :preferences, :smtp_password, :string
  end

  def self.down
    remove_column :preferences, :smtp_user_name
    remove_column :preferences, :smtp_password
  end
end


And editing config/initializers/email_settings.rb like so:

begin
  unless test?
    global_prefs = Preference.find(:first)
    if global_prefs.email_notifications?
      ActionMailer::Base.delivery_method = :smtp
      ActionMailer::Base.smtp_settings = {
        :address    => global_prefs.smtp_server,
        :port       => 25,
        :domain     => global_prefs.domain,
        :user_name  => global_prefs.smtp_user_name,
        :password   => global_prefs.smtp_password,
        :authentication => :login
      }
    end
  end
rescue
  # Rescue from the error raised upon first migrating
  # (needed to bootstrap the preferences).
  nil
end
Reply all
Reply to author
Forward
0 new messages