Hi Jim,
Im trying to use smtp.gmail.com for sending mail using rails
application. Currently Im using ruby 1.8 and so according to your
suggestion I copied the smtp.rb file in /net directory. But now Im
getting a new type of error when I try to send the mail. The error is
NoMethodError in EmailerController#sendmail
undefined method `lines’ for #String:0x343530c
RAILS_ROOT: C:/Alterum/email
Application Trace | Framework Trace | Full Trace
C:/ruby/lib/ruby/1.8/net/smtp.rb:988:in capabilities' C:/ruby/lib/ruby/1.8/net/smtp.rb:596:in
do_helo’
C:/ruby/lib/ruby/1.8/net/smtp.rb:555:in do_start' C:/ruby/lib/ruby/1.8/net/smtp.rb:525:in
start’
C:/ruby/lib/ruby/1.8/net/smtp.rb:463:in start' C:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/base.rb:586:in
perform_delivery_smtp’
C:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/base.rb:469:in
__send__' C:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/base.rb:469:in
deliver!’
C:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/base.rb:352:in
method_missing' app/controllers/emailer_controller.rb:6:in
sendmail’
Request
Parameters:
{“commit”=>“Send”,
“authenticity_token”=>“c7142102735203a9c277df1876f46862bd914641”,
“email”=>{“message”=>“Hi \r\nsAurav”,
“recipient”=>“[email protected]”,
“subject”=>“Hi”}}
my environment.rb file is
ActionMailer::Base.raise_delivery_errors = true;
ActionMailer::Base.delivery_method = :smtp;
ActionMailer::Base.smtp_settings = {
:address => “smtp.gmail.com”,
:port => 587,
:domain => “localhost.localdomain”,
:authentication => :plain,
:user_name => “username_of_gmail”,
:password => “password”,
}
Can you please tell me whats goin on ??
-Thanks
Saurav
Jim C. wrote:
I have successfully setup actionmailer with GMail, which gives full
pop3/smtp/imap access. Please note that GMail uses TLS for smtp
access, though. The Net::SMTP class for ruby 1.8.x doesn’t support
tls, however the same class does in ruby 1.9. I’d download smtp.rb
from ruby 1.9 and put it in your /lib directory:
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/net/smtp.rb?view=co
You also need a Net::POP3 which supports SSL:
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/net/pop.rb?view=co
Enter gmail’s POP3/SMTP configuration (available from google) into
your actionmailer config, and everything should work.
Jim C.