Hi, i am trying to send an email using RoR version 2.1.0 but i get some errors. I have this configuration:
1- In config/eviroment.rb, at the very end of my file:
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = { :address => "smtp.domain.com", :port => 25, :domain => "domain.com", :authentication => :login, :user_name => "user@domain.com", :password => "secret" }
ActionMailer::Base.default_content_type = "text/html" ActionMailer::Base.raise_delivery_errors = true
2- app/models/Emailer i have:
class Emailer < ActionMailer::Base def contact_email(email_params, sent_at = Time.now) @recipients = "someuser@gmail.com" @from = email_params[:name] + " <" + email_params[:address] + ">" @subject = email_params[:subject] @sent_on = sent_at @body["email_body"] = email_params[:body] @body["email_name"] = email_params[:name] end end
3- app/controllers/contact_controller i have:
class ContactController < ApplicationController def index end
def send_mail Emailer::deliver_contact_email(params[:email]) end
end
4- app/views/emailer/contact_email.rhtml i have: Name:
<%= @email_name %>
Message:
<%= @email_body %>
5- in app/view/contact/index.html.erb have: <% form_tag '/contact/send_mail' do %> <table> <tr> <td><label for="email_name">Name:</label></td> <td><%= text_field "email", "name", :size => 30 %></td> </tr> <tr> <td><label for="email_address">Email Address:</label></td> <td><%= text_field "email", "address", :size => 30 %></td> </tr> <tr> <td><label for="email_subject">Subject:</label></td> <td><%= text_field "email", "subject", :size => 30 %></td> </tr> <tr> <td><label for="email_body">Body:</label></td> <td><%= text_area "email", "body", :rows => 8, :cols => 30 %></
</tr> </table>
<%= submit_tag 'Send Email' %>
<% end -%>
5- Errors i got:
Net::SMTPSyntaxError (502 unimplemented (#5.5.1) ): /usr/lib/ruby/1.8/net/smtp.rb:948:in `check_auth_continue' /usr/lib/ruby/1.8/net/smtp.rb:740:in `auth_login' /usr/lib/ruby/1.8/net/smtp.rb:921:in `critical' .... .... ....
I have read a lot in different forums about the same problema but no solution found. I also asked to my hosting solution about smtp configuration, and they said that i am using the correct information about our smtp. So I do not have any idea of what i am doing wrong, need help please. Any idea?
Cheers