Hi every body,
I'm trying to user ar_mailer with gmail, I have followed the instructions given in this posts and got the following error :
Unhandled exception 530 5.7.0 Must issue a STARTTLS command first a2sm2577290pyi
(Net::SMTPAuthenticationError):
c:/ruby/lib/ruby/1.8/net/smtp.rb:577:in `auth_plain'
c:/ruby/lib/ruby/1.8/net/smtp.rb:571:in `__send__'
c:/ruby/lib/ruby/1.8/net/smtp.rb:571:in `authenticate'
c:/ruby/lib/ruby/1.8/net/smtp.rb:411:in `do_start'
c:/ruby/lib/ruby/gems/1.8/gems/ar_mailer-1.2.0/lib/smtp_tls.rb:29:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/ar_mailer-1.2.0/lib/smtp_tls.rb:29:in `start'
c:/ruby/lib/ruby/gems/1.8/gems/ar_mailer-1.2.0/lib/smtp_tls.rb:19:in `start'
c:/ruby/lib/ruby/gems/1.8/gems/ar_mailer-1.2.0/lib/action_mailer/ar_sendmail.rb:362:in `deliver'
c:/ruby/lib/ruby/gems/1.8/gems/ar_mailer-1.2.0/lib/action_mailer/ar_sendmail.rb:443:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/ar_mailer-1.2.0/lib/action_mailer/ar_sendmail.rb:440:in `loop'
c:/ruby/lib/ruby/gems/1.8/gems/ar_mailer-1.2.0/lib/action_mailer/ar_sendmail.rb:440:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/ar_mailer-1.2.0/lib/action_mailer/ar_sendmail.rb:311:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/ar_mailer-1.2.0/bin/ar_sendmail:5
c:/ruby/bin/ar_sendmail:18:in `load'
c:/ruby/bin/ar_sendmail:18
To sum up here's what I have done :
* install ar_mailer 1.2
* create a model :
class Email < ActiveRecord::Base
end
* create a mail notifier :
class UserNotifier < ActionMailer::ARMailer def send_to_friends(user, name, recipient, message)
@recipients = "#{recipient}"
@from = "#{user.email}"
@sent_on = Time.now
@body[:url] = "http://#{SITE_URL}"
@body[:recipient] = "#{recipient}"
@body[:user] = user
@body[:message] = "#{message}"
@body[:name] = "#{name}"
end
end
* in environment.rb :
require 'action_mailer/ar_mailer'
* in config/environments/development.rb :
require "smtp_tls"ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:authentication => :plain,
:domain => "xxx.com",
:user_name => "xxx@gmail.com",
:password => 'xxx'
}
ActionMailer::Base.delivery_method = :activerecord
* add a template :
Hi <%= @recipient %> !<% if !@message.nil? or @message.blank? -%>
<% if !@name.nil? -%>
<% @sender = "#{@name}(#{@user[:email]})"-%>
<% else -%>
<% @sender = "#{@user[:login]}(#{@user[:email]})"-%>
<% end-%>
<%= @sender-%> have send you the following message :
"<%= @message-%>"
<% end -%>
* and finally call the send method in one of my controllers:
UserNotifier.deliver_send_to_friends(current_user, params[:mail][:name], recipient, params[:mail][:message])
peburrows do you have any idea what's wrong ?
Tnaks so much in advance.
Addam
PS : I have also modified the file /lib/smtp_tls.rb such as indicated in http://blog.pomozov.info/posts/how-to-s
ilcom.html and works great without ar_mailer
Last edited by addam (2007-06-23 01:05:21)