Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6094

Show
Ignore:
Timestamp:
01/31/07 02:07:09 (3 years ago)
Author:
nzkoz
Message:

Deprecate server_settings renaming it to smtp_settings, add sendmail_settings to allow you to override the arguments to and location of the sendmail executable. [Koz]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1-2-stable/actionmailer/CHANGELOG

    r5984 r6094  
     1*SVN* 
     2 
     3* Deprecate server_settings renaming it to smtp_settings,  add sendmail_settings to allow you to override the arguments to and location of the sendmail executable. [Koz] 
     4 
    15*1.3.1* (January 16th, 2007) 
    26 
  • branches/1-2-stable/actionmailer/lib/action_mailer/base.rb

    r5081 r6094  
    185185  #   Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers. 
    186186  # 
    187   # * <tt>server_settings</tt> -  Allows detailed configuration of the server
     187  # * <tt>smtp_settings</tt> -  Allows detailed configuration for :smtp delivery method
    188188  #   * <tt>:address</tt> Allows you to use a remote mail server. Just change it from its default "localhost" setting. 
    189189  #   * <tt>:port</tt> On the off chance that your mail server doesn't run on port 25, you can change it. 
     
    194194  #     This is a symbol and one of :plain, :login, :cram_md5 
    195195  # 
     196  # * <tt>sendmail_settings</tt> - Allows you to override options for the :sendmail delivery method 
     197  #   * <tt>:location</tt> The location of the sendmail executable, defaults to "/usr/sbin/sendmail" 
     198  #   * <tt>:arguments</tt> The command line arguments 
    196199  # * <tt>raise_delivery_errors</tt> - whether or not errors should be raised if the email fails to be delivered. 
    197200  # 
    198201  # * <tt>delivery_method</tt> - Defines a delivery method. Possible values are :smtp (default), :sendmail, and :test. 
    199   #   Sendmail is assumed to be present at "/usr/sbin/sendmail". 
    200202  # 
    201203  # * <tt>perform_deliveries</tt> - Determines whether deliver_* methods are actually carried out. By default they are, 
     
    229231    cattr_accessor :logger 
    230232 
    231     @@server_settings = {  
     233    @@smtp_settings = {  
    232234      :address        => "localhost",  
    233235      :port           => 25,  
     
    237239      :authentication => nil 
    238240    } 
    239     cattr_accessor :server_settings 
     241    cattr_accessor :smtp_settings 
     242     
     243    @@sendmail_settings = { 
     244      :location       => '/usr/sbin/sendmail', 
     245      :arguments      => '-i -t' 
     246    } 
     247    cattr_accessor :sendmail_settings 
    240248 
    241249    @@raise_delivery_errors = true 
     
    356364        new.deliver!(mail) 
    357365      end 
     366       
     367      # Server Settings is the old name for <tt>smtp_settings</tt> 
     368      def server_settings 
     369        smtp_settings 
     370      end 
     371      deprecate :server_settings=>"It's now named smtp_settings" 
     372       
     373      def server_settings=(settings) 
     374        ActiveSupport::Deprecation.warn("server_settings has been renamed smtp_settings, this warning will be removed with rails 2.0", caller) 
     375        self.smtp_settings=settings 
     376      end 
     377       
    358378    end 
    359379 
     
    543563        mail.ready_to_send 
    544564 
    545         Net::SMTP.start(server_settings[:address], server_settings[:port], server_settings[:domain],  
    546             server_settings[:user_name], server_settings[:password], server_settings[:authentication]) do |smtp| 
     565        Net::SMTP.start(smtp_settings[:address], smtp_settings[:port], smtp_settings[:domain],  
     566            smtp_settings[:user_name], smtp_settings[:password], smtp_settings[:authentication]) do |smtp| 
    547567          smtp.sendmail(mail.encoded, mail.from, destinations) 
    548568        end 
     
    550570 
    551571      def perform_delivery_sendmail(mail) 
    552         IO.popen("/usr/sbin/sendmail -i -t","w+") do |sm| 
     572        IO.popen("#{sendmail_settings[:location]} #{sendmail_settings[:arguments]}","w+") do |sm| 
    553573          sm.print(mail.encoded.gsub(/\r/, '')) 
    554574          sm.flush 
  • branches/1-2-stable/actionmailer/test/mail_service_test.rb

    r5081 r6094  
    788788    assert_match %r{charset=utf-8}, mail['content-type'].to_s 
    789789  end 
     790   
     791  def test_deprecated_server_settings 
     792    old_smtp_settings = ActionMailer::Base.smtp_settings 
     793    assert_deprecated do 
     794      ActionMailer::Base.server_settings 
     795    end 
     796    assert_deprecated do 
     797      ActionMailer::Base.server_settings={} 
     798      assert_equal Hash.new, ActionMailer::Base.smtp_settings 
     799    end 
     800  ensure 
     801    ActionMailer::Base.smtp_settings=old_smtp_settings     
     802  end 
    790803end 
    791804