0

im trying to implement a simple form for my ruby website using pony and i keep getting the error '535-5.7.1 Username and Password not accepted.' I've typed in my own gmail username and password in the correct fields.

code in pony.rb

Pony.options = {
:to => 'myusername',
:via => :smtp,: 
:via_options => {
:address              => 'smtp.gmail.com',
:port                 => '587',
:enable_starttls_auto => true,
:user_name            => 'myusername',
:password             => 'mypassword',
:authentication       => :plain, # :plain, :login, :cram_md5, no auth by default
:domain               => "localhost.localdomain" # the HELO domain provided by the    client to the server
}
}
Arvid Boome
  • 49
  • 1
  • 11

1 Answers1

0

See the WORKING code below. Just tested this with my gmail.

Pony.mail(:to => 'someone@acme.com', :via => :smtp, :via_options => 
{
    :address => 'smtp.gmail.com',                     
    :port => '587',
    :enable_starttls_auto => true,
    :user_name => 'yourgmail@gmail.com',
    :password => 'yourpass',
    :authentication => :plain,
    :domain => "HELO",
 },
:subject => 'Your Subject goes here', :body => "bla bla bla or #{$body}",       
:attachments => {"yourfile.txt" => File.binread("c:/ruby193/bin/yourfile.txt")    
}
)

Best of luck Arvid let me know if you need further help!

Xwris Stoixeia
  • 1,831
  • 21
  • 22
  • hi i've implemented what you said but now i get the error :to is required – Arvid Boome Mar 16 '13 at 18:31
  • app/models/inquiry.rb:29:in `deliver' app/controllers/inquiries_controller.rb:9:in `create' – Arvid Boome Mar 16 '13 at 18:32
  • def deliver return false unless valid? Pony.mail({ :from => %("#{name}" <#{email}>), :reply_to => email, :subject => "Website inquiry", :body => message, :html_body => simple_format(message) }) end – Arvid Boome Mar 16 '13 at 18:33
  • def create (at)inquiry = Inquiry.new(params[:inquiry]) if @inquiry.deliver render :thank_you else render :new end end – Arvid Boome Mar 16 '13 at 18:34