<?xml version="1.0" encoding="UTF-8"?>
<issue>
  <id>1598</id>
  <project name="Redmine" id="1"/>
  <tracker name="Defect" id="1"/>
  <status name="Closed" id="5"/>
  <priority name="Normal" id="4"/>
  <author name="Calvin Cheng" id="878"/>
  <assigned_to name="Jean-Philippe Lang" id="1"/>
  <category name="Email notifications" id="9"/>
  <subject>r1643 broke action_mailer_optional_tls</subject>
  <description>Hi,

I am tracking the trunk and have just upgraded my redmine installation to r1643.

After upgrading from r1410 (and reinstalling this plugin of course), gmail smtp support no longer works.  I was using the solution from here: http://douglasfshearer.com/blog/gmail-smtp-with-ruby-on-rails-and-actionmailer and it has been working fine when I was still in r1410.

I noted that it is necessary to place the smtp settings in a separate file named email.yml under the config folder and I have done just that.  However, the same error occurs even after restarting the redmine instance.

The error message I get when sending a test mail is "An error occurred while sending mail (wrong number of arguments (3 for 2))".

Hope you can look into it.  

Thank you.
</description>
  <start_date>2008-07-07</start_date>
  <due_date></due_date>
  <done_ratio>100</done_ratio>
  <estimated_hours></estimated_hours>
  <custom_fields>
    <custom_field name="Affected version" id="1"></custom_field>
    <custom_field name="Resolution" id="2"></custom_field>
  </custom_fields>
  <created_on>Mon Jul 07 21:48:59 +0200 2008</created_on>
  <updated_on>Wed Jul 16 20:53:29 +0200 2008</updated_on>
  <journals>
    <journal id="3777">
      <user name="Jean-Philippe Lang" id="1"/>
      <notes>redmine.org runs latest trunk and uses gmail + action_mailer_optional_tls.
Could you post your email.yml ?</notes>
      <details>
      </details>
    </journal>
    <journal id="3778">
      <user name="Victor Palma" id="1532"/>
      <notes>I'm running version 0.7.3 and it works fine. You might need to install the plugin again i ran the following command and it worked for me.
 ./script/plugin install http://svn.douglasfshearer.com/rails/plugins/action_mailer_optional_tl again. 

Regards</notes>
      <details>
      </details>
    </journal>
    <journal id="3781">
      <user name="Burt Culver" id="1538"/>
      <notes>Hi,

I am on the tip of the trunk as well and tried reinstalling action_mailer_optional_tls as suggested but still get the "An error occurred while sending mail (wrong number of arguments (3 for 2))" error.

rails 2.1.0
ruby 1.8.7
gem 1.2.0

My email.yml file:

production:
  delivery_method: :smtp
  smtp_settings:
    address: smtp.google.com
    port: 587
    domain: example.com
    authentication: :login
    user_name: redmine@example.com
    password: XXXXX
    tls: true

Thanks for any help.

Burt
</notes>
      <details>
      </details>
    </journal>
    <journal id="3786">
      <user name="Calvin Cheng" id="878"/>
      <notes>Burt Culver wrote:
&gt; Hi,
&gt; 
&gt; I am on the tip of the trunk as well and tried reinstalling action_mailer_optional_tls as suggested but still get the "An error occurred while sending mail (wrong number of arguments (3 for 2))" error.
&gt; 
&gt; rails 2.1.0
&gt; ruby 1.8.7
&gt; gem 1.2.0
&gt; 
&gt; My email.yml file:
&gt; 
&gt; production:
&gt;   delivery_method: :smtp
&gt;   smtp_settings:
&gt;     address: smtp.google.com
&gt;     port: 587
&gt;     domain: example.com
&gt;     authentication: :login
&gt;     user_name: redmine@example.com
&gt;     password: XXXXX
&gt;     tls: true
&gt; 
&gt; Thanks for any help.
&gt; 
&gt; Burt

Hi,

My versions are similar:
&gt; rails 2.1.0
&gt; ruby 1.8.7
&gt; gem 1.2.0

I have tried using Burt's email settings above as well and instead of authentication: :login, I also tried out authentication: :plain. Both gave the same error.

</notes>
      <details>
      </details>
    </journal>
    <journal id="3789">
      <user name="Jean-Philippe Lang" id="1"/>
      <notes></notes>
      <details>
        <detail old="5" name="fixed_version_id" property="attr" new=""/>
      </details>
    </journal>
    <journal id="3798">
      <user name="Burt Culver" id="1538"/>
      <notes>I added a raise of the error to app/controllers/admin_controller.rb in order to get a stack trace.  Here it is:

ArgumentError (wrong number of arguments (3 for 2)):
    /vendor/plugins/action_mailer_optional_tls/lib/smtp_tls.rb:33:in `check_auth_args'
    /vendor/plugins/action_mailer_optional_tls/lib/smtp_tls.rb:33:in `do_tls_start'
    /vendor/plugins/action_mailer_optional_tls/lib/smtp_tls.rb:18:in `send'
    /vendor/plugins/action_mailer_optional_tls/lib/smtp_tls.rb:18:in `start'
    /vendor/plugins/action_mailer_optional_tls/lib/smtp_tls.rb:10:in `start'
    /vendor/plugins/action_mailer_optional_tls/lib/action_mailer_tls.rb:9:in `perform_delivery_smtp'
    /usr/local/lib/ruby/gems/1.8/gems/actionmailer-2.1.0/lib/action_mailer/base.rb:508:in `__send__'
    /usr/local/lib/ruby/gems/1.8/gems/actionmailer-2.1.0/lib/action_mailer/base.rb:508:in `deliver!'
    /app/models/mailer.rb:154:in `deliver!'
    /usr/local/lib/ruby/gems/1.8/gems/actionmailer-2.1.0/lib/action_mailer/base.rb:383:in `method_missing'
    /app/controllers/admin_controller.rb:68:in `test_email'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:1162:in `send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:1162:in `perform_action_without_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/filters.rb:580:in `call_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/filters.rb:573:in `perform_action_without_benchmark'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/rescue.rb:201:in `perform_action_without_caching'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/query_cache.rb:8:in `cache'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:529:in `send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:529:in `process_without_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/filters.rb:569:in `process_without_session_management_support'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/session_management.rb:130:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:389:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:149:in `handle_request'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:107:in `dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:104:in `synchronize'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:104:in `dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:120:in `dispatch_cgi'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:35:in `dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `synchronize'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:159:in `process_client'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `process_client'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `initialize'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `new'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `initialize'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `new'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:282:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
    /usr/local/bin/mongrel_rails:19:in `load'
    /usr/local/bin/mongrel_rails:19
</notes>
      <details>
      </details>
    </journal>
    <journal id="3799">
      <user name="Burt Culver" id="1538"/>
      <notes>removing authtype from the call to check_auth_args on line 33 of vendor/plugins/action_mailer_optional_tls/lib/smtp_tls.rb fixes the problem.  Looks like a bug in action_mailer_optional_tls rather than redmine.

Looks like Net::SMTP changed the function signature for check_auth_args.  Bad programmer - no red bull for you.

Burt</notes>
      <details>
      </details>
    </journal>
    <journal id="3803">
      <user name="Calvin Cheng" id="878"/>
      <notes>Perfect!

Thanks for the solution Burt.
</notes>
      <details>
      </details>
    </journal>
    <journal id="3804">
      <user name="Calvin Cheng" id="878"/>
      <notes></notes>
      <details>
        <detail old="1" name="status_id" property="attr" new="3"/>
        <detail old="0" name="done_ratio" property="attr" new="100"/>
      </details>
    </journal>
    <journal id="3947">
      <user name="Jean-Philippe Lang" id="1"/>
      <notes></notes>
      <details>
        <detail old="3" name="status_id" property="attr" new="5"/>
        <detail old="devel" name="1" property="cf" new=""/>
      </details>
    </journal>
  </journals>
</issue>
