coffeeexistence / substruct

Automatically exported from code.google.com/p/substruct
0 stars 0 forks source link

SMTP with no authentication should set ActionMailer setting to nil instead of :none #120

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Try to use the setting for no authentication on SMTP in the Preferences
page (SMTP Authentication Type: none). Emails will not send and
ActionMailer will give an error like:

ArgumentError: wrong auth type none
    from /usr/lib/ruby/1.8/net/smtp.rb:566:in `check_auth_args'

What is the expected output? What do you see instead?
Emails should send with no ActionMailer errors when SMTP is set to have no
authentication.

What version of the product are you using? On what operating system?
1.0.a3 on Ubuntu Hardy (8.04). Rails 2.0.2.

Please provide any additional information below.

According to this post: http://www.ruby-forum.com/topic/106218 ,
ActionMailer::Base.smtp_settings[:authentication] should be set to nil, not
:none when using SMTP with no authentication. I've changed the relevant
section in app/models/preference.rb to this which seems to work for me:

    if mail_auth_type != 'none'
      mail_server_settings[:authentication] = mail_auth_type.to_sym
      mail_server_settings[:user_name] = find_by_name('mail_username').value
      mail_server_settings[:password] = find_by_name('mail_password').value
    else
     mail_server_settings[:authentication] = nil
    end
    ActionMailer::Base.smtp_settings = mail_server_settings

Original issue reported on code.google.com by afiedl...@gmail.com on 20 Aug 2008 at 5:43

GoogleCodeExporter commented 8 years ago
I cannot reproduce this, configured my own Postfix server to not have 
authentication
available and testing using the :none type sends the message.

More info:

Server output:
edmundo@toshibau305:~$ telnet 192.168.0.6 25
Trying 192.168.0.6...
Connected to 192.168.0.6.
Escape character is '^]'.
220 internetgw.intranet.minharede.lan ESMTP Postfix (Debian/GNU)
ehlo localhost
250-internetgw.intranet.minharede.lan
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250 8BITMIME
...

Test used:

  def test_receipt_not_using_authentication
    ActionMailer::Base.delivery_method = :smtp

    prefs = {
      "mail_host" => "192.168.0.6",
      "mail_port" => "25",
      "mail_auth_type" => "none",
      "mail_username" => "usuario1@minharede.lan"
    }

    assert Preference.save_settings(prefs)
    assert Preference.init_mail_settings

    an_order_user = order_users(:santa)
    assert an_order_user.update_attributes(:email_address => 'usuario2@minharede.lan')

    # Get any order.
    an_order = orders(:santa_next_christmas_order)

    an_order.deliver_receipt
  end

Original comment by edmundo...@gmail.com on 21 Aug 2008 at 11:25

GoogleCodeExporter commented 8 years ago
obs.: Tested on trunk, commenting out the requirement of the smtp_tls unit in 
the
preference model.

Original comment by edmundo...@gmail.com on 21 Aug 2008 at 11:28